/* ===== Base & Theme ===== */
:root,
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-raised: #1c1c1c;
  --border: #262626;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --accent: #ff7a1a;           /* ping pong ball orange */
  --accent-hover: #ff9142;
  --accent-soft: rgba(255, 122, 26, 0.12);
  --lime: #a3e635;
  --lime-soft: rgba(163, 230, 53, 0.12);
  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.12);
  --loss: #f87171;
  --loss-soft: rgba(248, 113, 113, 0.12);
  --gold: #fbbf24;
  --silver: #d4d4d8;
  --bronze: #d0814a;
  --radius: 10px;
  --display-font: 'Chakra Petch', 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Pico overrides so its form controls and buttons follow the theme */
  --pico-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--text-muted);
  --pico-muted-border-color: var(--border);
  --pico-primary: var(--accent);
  --pico-primary-background: var(--accent);
  --pico-primary-border: var(--accent);
  --pico-primary-underline: rgba(255, 122, 26, 0.5);
  --pico-primary-hover: var(--accent-hover);
  --pico-primary-hover-background: var(--accent-hover);
  --pico-primary-hover-border: var(--accent-hover);
  --pico-primary-hover-underline: var(--accent-hover);
  --pico-primary-focus: rgba(255, 122, 26, 0.35);
  --pico-primary-inverse: #0a0a0a;
  --pico-form-element-background-color: var(--surface-raised);
  --pico-form-element-border-color: #333333;
  --pico-form-element-active-background-color: var(--surface-raised);
  --pico-form-element-active-border-color: var(--accent);
  --pico-form-element-focus-color: rgba(255, 122, 26, 0.35);
  --pico-card-background-color: var(--surface);
  --pico-table-border-color: var(--border);
}

html {
  background: var(--bg);
}

/* Transparent so the fixed arena layer below shows through */
body {
  background: transparent;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* Arena background with a light tint: a fixed layer (works on mobile, unlike
   background-attachment: fixed). Cards stay opaque enough to keep content readable. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(10, 10, 10, 0.25), rgba(10, 10, 10, 0.25)),
    url('/img/arena-bg.webp') center 65% / cover no-repeat;
}

main.container {
  max-width: 960px;
  padding-top: 0;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

main.container.container-wide {
  max-width: 1400px;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

/* ===== Site Banner ===== */
.site-banner {
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 24px rgba(255, 122, 26, 0.18);
  padding: 0.75rem 0;
  margin-bottom: 2.25rem;
}

.banner-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-logo {
  height: 2rem;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  padding-left: 1rem;
  border-left: 1px solid #2a2a2a;
}

/* Navigation links */
.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.site-nav a {
  font-family: var(--display-font);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: var(--text-muted);
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.site-nav a.nav-active {
  color: #0a0a0a;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(255, 122, 26, 0.45);
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 1.75rem;
  /* Titles sit directly on the bright background */
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.9);
}

.page-header h1,
.admin-header h1 {
  font-family: var(--display-font);
  margin-bottom: 0.25rem;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}

.page-header h1::after {
  content: '';
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.4rem;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent), var(--lime));
}

.page-header p {
  color: var(--text);
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* ===== Cards ===== */
.card {
  background: rgba(20, 20, 20, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

/* Lets the player picker's dropdown extend past the card. The blur on cards makes each one
   its own layer, so the form card is lifted above the cards that follow it. */
.card.card-form {
  overflow: visible;
  position: relative;
  z-index: 10;
}

.card h2 {
  font-family: var(--display-font);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  color: var(--text);
}

.card h2.card-title-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.card-title-row h2 { margin: 0; }

/* ===== Tables ===== */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin-bottom: 0;
}

table thead th {
  background: var(--surface-raised);
  font-family: var(--display-font);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
}

table tbody td {
  background: transparent;
  color: var(--text);
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody tr:hover td {
  background: var(--accent-soft);
}

/* ===== Leaderboard ===== */
.rank-badge,
.rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.rank-badge {
  border-radius: 50%;
  border: 2px solid currentColor;
  background: #0f0f0f;
}

.rank-1 { color: var(--gold);   box-shadow: 0 0 14px rgba(251, 191, 36, 0.45); }
.rank-2 { color: var(--silver); box-shadow: 0 0 12px rgba(212, 212, 216, 0.3); }
.rank-3 { color: var(--bronze); box-shadow: 0 0 12px rgba(208, 129, 74, 0.4); }

.rank-number {
  color: var(--text-muted);
}

.podium-row td {
  background: rgba(255, 255, 255, 0.025);
}

.podium-line td {
  padding: 0.35rem 0 !important;
  border-bottom: none !important;
}

.podium-line:hover td {
  background: transparent !important;
}

.podium-divider {
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, transparent, var(--accent), var(--lime), transparent);
}

.player-name {
  font-weight: 600;
}

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

.elo {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue);
  letter-spacing: 0.03em;
}

.elo-unranked {
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== Score Entry ===== */
.score-grid-header,
.score-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.score-row[hidden] {
  display: none;
}

.score-game-label {
  font-family: var(--display-font);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.score-player-label {
  font-family: var(--display-font);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Player picker: name + ELO badge (replaces the native select on the match form) */
.picker-native {
  display: none !important;
}

.picker {
  position: relative;
  margin-bottom: var(--pico-spacing);
}

.picker-button {
  position: relative;
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 2.6rem 0.7rem 1rem;
  text-align: left;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid #333333;
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
}

.picker-button::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: -0.35rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
}

.picker-button:hover:not(:disabled),
.picker-button[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--surface-raised);
  color: var(--text);
}

.picker-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.picker-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.picker-placeholder .picker-name {
  color: var(--text-muted);
}

.picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 18rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: #181818;
  border: 1px solid #333333;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

.picker-list:focus {
  outline: none;
}

.picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0;
  padding: 0.5rem 0.7rem;
  list-style: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.picker-option.active,
.picker-option:hover {
  background: var(--accent-soft);
}

.picker-option[aria-selected="true"] .picker-name {
  color: var(--accent);
  font-weight: 600;
}

.elo-badge {
  flex-shrink: 0;
  padding: 0.05rem 0.5rem;
  font-family: var(--display-font);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
}

/* Score with always-visible -/+ buttons */
.score-stepper {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
}

.score-input {
  flex: 1;
  min-width: 0;
  margin: 0 !important;
  font-family: var(--display-font);
  font-size: 1.25rem !important;
  font-weight: 700;
  text-align: center;
  padding: 0.35rem !important;
  -moz-appearance: textfield;
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  flex: 0 0 2.6rem;
  margin: 0;
  padding: 0;
  font-family: var(--display-font);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  background: var(--surface-raised);
  border: 1px solid #333333;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.step-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.step-btn:active {
  background: var(--accent);
  color: #0a0a0a;
}

.step-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.winner-preview {
  margin-top: 0.85rem;
  font-size: 0.92rem;
}

.elo-projection {
  margin: 0 0 1.25rem;
}

.stake-table {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
}

.stake-table thead th {
  background: #222222;
}

.stake-table td,
.confirm-table td {
  font-size: 0.88rem;
  padding: 0.45rem 0.75rem;
}

.stake-table td.stat,
.confirm-table td.stat {
  font-family: var(--display-font);
  font-size: 1rem;
}

/* ===== Confirmation dialog ===== */
dialog#confirm-dialog > article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
}

dialog#confirm-dialog > article > header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}

dialog#confirm-dialog h3 {
  font-family: var(--display-font);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

dialog#confirm-dialog > article > footer {
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

dialog#confirm-dialog > article > footer button {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confirm-winner {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.confirm-winner-name {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--lime);
  margin-right: 0.4rem;
}

.confirm-table {
  margin-bottom: 1rem;
}

.score-final {
  color: var(--text-muted);
}

.score-final.score-won {
  color: var(--text);
  font-weight: 700;
}

.confirm-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.score-cell {
  font-family: var(--display-font);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.elo-change {
  margin-left: 0.3rem;
  font-family: var(--display-font);
  font-size: 0.85rem;
  white-space: nowrap;
}

.pts-positive { color: var(--lime); font-weight: 700; }
.pts-negative { color: var(--loss); font-weight: 700; }
.pts-zero     { color: var(--text-muted); }

.points-balance {
  font-family: var(--display-font);
}

/* ===== Match History ===== */
.winner-tag {
  display: inline-block;
  background: var(--lime-soft);
  color: var(--lime);
  border: 1px solid rgba(163, 230, 53, 0.35);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ===== Status Badges ===== */
.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-active {
  background: var(--lime-soft);
  color: var(--lime);
}

.badge-inactive {
  background: #1f1f1f;
  color: var(--text-muted);
}

/* ===== Forms ===== */
form label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

select, input[type="date"], input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  border-radius: 8px;
  font-size: 0.92rem;
}

input[type="date"] {
  color-scheme: dark;
}

button[type="submit"] {
  font-family: var(--display-font);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

button[type="submit"]:not(.outline):not(:disabled) {
  box-shadow: 0 0 18px rgba(255, 122, 26, 0.3);
}

button[type="submit"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ===== Flash Messages ===== */
.flash {
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash::before {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.flash-success {
  background: var(--lime-soft);
  color: var(--lime);
  border: 1px solid rgba(163, 230, 53, 0.35);
}

.flash-success::before {
  content: "\2713";
}

.flash-error {
  background: var(--loss-soft);
  color: var(--loss);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.flash-error::before {
  content: "\2717";
}

/* ===== Admin ===== */
.actions-cell {
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0.25rem 0 0;
}

.btn-sm {
  padding: 0.25rem 0.6rem !important;
  margin: 0 !important;
  font-size: 0.75rem !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.rank-input {
  width: 3.5rem !important;
  padding: 0.25rem 0.35rem !important;
  margin: 0 !important;
  display: inline-block;
  font-size: 0.85rem;
  text-align: center;
  border-radius: 6px !important;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.admin-header .page-header {
  margin-bottom: 0;
}

.admin-header a {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn-danger {
  color: var(--loss) !important;
  border-color: rgba(248, 113, 113, 0.5) !important;
}

.btn-danger:hover {
  background: var(--loss-soft) !important;
  border-color: var(--loss) !important;
}

/* Admin login centered */
.login-card {
  max-width: 380px;
  margin: 3rem auto;
}

/* ===== Rules ===== */
.rules-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.rules-grid .card {
  margin-bottom: 0;
  border-left: 3px solid var(--accent);
}

.rules-grid .card h3 {
  font-family: var(--display-font);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.rules-grid .card p,
.rules-grid .card li {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.rules-grid .card p:last-child {
  margin-bottom: 0;
}

.rules-grid .card strong {
  color: var(--text);
}

.rules-grid .card ul {
  padding-left: 1.25rem;
  margin-bottom: 0;
}

.rules-grid .card li::marker {
  color: var(--accent);
}

.rules-table {
  margin-top: 1rem;
}

.rules-table td {
  font-family: var(--display-font);
  font-weight: 700;
}

/* ===== Statistics ===== */
:root,
[data-theme="dark"] {
  /* Player colours for the stats charts, in a fixed order that stays telling apart under colour blindness */
  --stats-s1: #3987e5;
  --stats-s2: #d95926;
  --stats-s3: #199e70;
  --stats-s4: #c98500;
  --stats-s5: #d55181;
  --stats-s6: #008300;
  --stats-s7: #9085e9;
  --stats-s8: #e66767;
  --stats-s-other: #6f6f6f;
  --stats-tie: #4b4b4b;
}

.stats-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stats-tile {
  background: rgba(20, 20, 20, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  min-width: 0;
}

.stats-tile .k {
  font-family: var(--display-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stats-tile .v {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.2rem;
  color: var(--text);
}

.stats-tile .s {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stats-help {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.stats-chord-card {
  padding: 1.25rem 1.5rem 1rem;
}

.stats-chord-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.stats-chord-figure {
  margin: 0;
  min-width: 0;
}

.stats-chord-figure svg {
  width: 100%;
  height: auto;
  max-width: 760px;
  margin: 0 auto;
  display: block;
}

/* Dense tables: nine numeric columns have to fit beside each other */
#stats-players thead th,
#stats-rivals thead th {
  padding: 0.5rem 0.6rem;
  white-space: nowrap;
}

#stats-players tbody td,
#stats-rivals tbody td {
  padding: 0.5rem 0.6rem;
}

.stats-arc { cursor: pointer; }
.stats-arc:focus { outline: none; }
.stats-arc:focus-visible { stroke: var(--text); stroke-width: 2; }
.stats-ribbon { cursor: pointer; fill-opacity: 0.72; stroke: var(--surface); stroke-width: 1; }
.stats-ribbon:focus { outline: none; }
.stats-ribbon.dim, .stats-arc.dim { fill-opacity: 0.08; }
.stats-ribbon.hot { fill-opacity: 0.95; }
.stats-lbl { font: 600 13px var(--pico-font-family); fill: var(--text); pointer-events: none; }
.stats-lbl.dim { fill-opacity: 0.25; }
.stats-cnt { font: 500 11px var(--pico-font-family); fill: var(--text-muted); }

@media (prefers-reduced-motion: no-preference) {
  .stats-ribbon, .stats-arc, .stats-lbl { transition: fill-opacity 160ms ease; }
}

.stats-panel {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  min-width: 0;
  display: grid;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.stats-panel .ptitle {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.3;
  color: var(--text);
}

.stats-panel .ptitle .stats-swatch {
  vertical-align: 0.05em;
}

.stats-panel .big {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stats-panel .big small {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

.stats-panel .rows { display: grid; gap: 0.25rem; }
.stats-panel .rows div { display: flex; justify-content: space-between; gap: 0.6rem; }
.stats-panel .rows span:first-child { color: var(--text-muted); white-space: nowrap; }
.stats-panel .rows span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.stats-panel .hint { color: var(--text-muted); font-size: 0.78rem; }
.stats-panel .pin { color: var(--accent); font-size: 0.78rem; font-weight: 600; }

.stats-panel .opps { display: grid; gap: 0.2rem; }
.stats-panel .opps div { display: flex; align-items: center; gap: 0.5rem; }
.stats-panel .opps .n { width: 4.2rem; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-panel .opps .r { width: 2.2rem; flex: none; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.stats-panel .opps .bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; display: flex; }
.stats-panel .opps .bar i { display: block; height: 100%; background: var(--lime); }
.stats-panel .opps .bar b { display: block; height: 100%; background: var(--loss); }

.stats-swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  margin-right: 0.5rem;
  flex: none;
  vertical-align: 0;
}

#stats-players td, #stats-rivals td { white-space: nowrap; }
#stats-players tr.hl td, #stats-rivals tr.hl td { background: var(--accent-soft); }
.stats-lead { color: var(--lime); font-weight: 700; }
.stats-even { color: var(--text-muted); }
.stats-streak.w { color: var(--lime); font-weight: 600; }
.stats-streak.l { color: var(--loss); font-weight: 600; }

.stats-notables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.stats-note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.stats-note .k {
  font-family: var(--display-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.stats-note .v { font-weight: 700; font-size: 1rem; line-height: 1.25; color: var(--text); }
.stats-note .s { color: var(--text-muted); font-size: 0.82rem; }

/* ===== Player overlay ===== */
/* A player's name anywhere on the site is a button that opens their overlay */
.player-link {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-bottom: 1px dotted var(--text-muted);
}

.player-link:hover,
.player-link:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
  outline: none;
}

.winner-tag .player-link {
  color: inherit;
  border-bottom-color: transparent;
}

.winner-tag .player-link:hover,
.winner-tag .player-link:focus-visible {
  border-bottom-color: currentColor;
}

dialog#player-dialog > article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  max-width: 980px;
  width: 100%;
  padding: 0;
}

dialog#player-dialog > article > header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.9rem 1.25rem;
}

dialog#player-dialog h3 {
  font-family: var(--display-font);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 1.4rem;
  margin: 0;
}

.po-close {
  all: unset;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.po-close:hover,
.po-close:focus-visible {
  color: var(--text);
  background: var(--accent-soft);
}

.po-body {
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

.po-loading {
  color: var(--text-muted);
  margin: 0;
}

.po-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.po-tile {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  min-width: 0;
}

.po-tile .k {
  font-family: var(--display-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.po-tile .v {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.2rem;
  color: var(--text);
}

.po-tile .s {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.po-section {
  display: grid;
  gap: 0.5rem;
}

.po-section h4 {
  font-family: var(--display-font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text);
}

.po-charthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.po-note {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.po-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.po-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.po-legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); }
.po-legend i.o { border-top-color: #4a4a4a; }

.po-chartbox {
  position: relative;
  min-width: 0;
}

.po-chartbox svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

.po-overlay { fill: transparent; cursor: crosshair; }
.po-overlay:focus { outline: none; }
.po-overlay:focus-visible { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; }
.po-axis text { font: 500 11px var(--pico-font-family); fill: var(--text-muted); }
.po-grid { stroke: #232323; }
.po-tick { stroke: #333333; }
.po-baseline { stroke: #333333; }
.po-other { fill: none; stroke: #4a4a4a; stroke-width: 1.5; }
.po-me { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.po-mearea { fill: var(--accent); fill-opacity: 0.08; }
.po-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.po-dot.loss { fill: var(--surface); stroke: var(--accent); }
.po-xline { stroke: var(--text); stroke-opacity: 0.5; stroke-width: 1; }
.po-xdot { fill: var(--text); stroke: var(--accent); stroke-width: 2; }
.po-endlabel { font: 700 12px var(--pico-font-family); fill: var(--text); }

.po-tip {
  position: absolute;
  top: 8px;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid #333333;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  min-width: 150px;
  max-width: 240px;
  display: none;
  z-index: 2;
}

.po-tip.show { display: block; }
.po-tip .d { color: var(--text-muted); }
.po-tip .big { font-size: 1.3rem; font-weight: 700; line-height: 1.1; margin: 0.1rem 0; }
.po-tip .big small { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); margin-left: 0.3rem; }
.po-tip .m { margin-top: 0.25rem; }

.po-table {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#po-matches td, #po-matches th { white-space: nowrap; }
#po-matches tr.hl td { background: var(--accent-soft); }
.po-res.w { color: var(--lime); font-weight: 700; }
.po-res.l { color: var(--loss); font-weight: 600; }

/* ===== Footer ===== */
.site-footer {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.9);
  text-align: center;
  padding: 2.5rem 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-brand {
  font-family: var(--display-font);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ===== Empty States ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1rem;
}

.empty-hint {
  font-size: 0.85rem !important;
  opacity: 0.8;
  margin-top: 0.25rem !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  main.container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .banner-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1rem;
  }

  .topbar-title {
    font-size: 0.9rem;
    padding-left: 0.75rem;
  }

  .site-nav {
    order: 3;
    width: 100%;
    gap: 0;
    margin-left: 0;
    justify-content: space-between;
  }

  .site-nav a {
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    padding: 0.3rem 0.45rem;
  }

  .page-header h1,
  .admin-header h1 {
    font-size: 1.6rem;
  }

  table thead th,
  table tbody td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  .rank-badge,
  .rank-number {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }

  .card {
    padding: 1rem;
  }

  .score-grid-header,
  .score-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.5rem;
  }

  /* Game label sits above its row instead of in a narrow column */
  .score-grid-header > span:first-child {
    display: none;
  }

  .score-game-label {
    grid-column: 1 / -1;
  }

  .score-stepper {
    gap: 0.2rem;
  }

  .step-btn {
    flex-basis: 2rem;
    font-size: 1.1rem;
  }

  .score-input {
    font-size: 1.05rem !important;
    padding: 0.3rem 0.1rem !important;
  }

  .hide-mobile {
    display: none;
  }

  .stats-chord-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stats-chord-card {
    padding: 1rem;
  }

  .stats-tile .v {
    font-size: 1.5rem;
  }

  .po-body {
    padding: 0.9rem;
    gap: 0.9rem;
  }

  .po-tile .v {
    font-size: 1.4rem;
  }
}
