*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f172a;
  --surface:  #1e293b;
  --border:   #334155;
  --text:     #f1f5f9;
  --subtext:  #94a3b8;
  --accent:   #3b82f6;
  --green:    #22c55e;
  --red:      #ef4444;
  --gold:     #f59e0b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 0 0 2rem;
}

/* ── Header ─────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}

#last-updated {
  color: var(--subtext);
  font-size: 0.8rem;
  width: 100%;
}

/* ── Sections ────────────────────────────────────────── */
.section {
  margin: 1.25rem auto;
  max-width: 640px;
  padding: 0 1rem;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtext);
  margin-bottom: 0.75rem;
}

/* ── Leaderboard Table ───────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

tr:hover td { background: rgba(255,255,255,0.03); }

.col-rank  { font-size: 1rem; width: 2.5rem; text-align: center; }
.col-name  { font-weight: 600; }
.col-elo   { font-weight: 700; font-variant-numeric: tabular-nums; }
.col-record { color: var(--subtext); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.col-delta { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--subtext); }

/* ── Movers ──────────────────────────────────────────── */
.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.mover-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ── Form (matchday.html) ────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label, .field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="date"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.radio-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.radio-btn {
  flex: 1;
  min-width: 80px;
}

.radio-btn input[type="radio"] {
  display: none;
}

.radio-btn label {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.radio-btn input[type="radio"]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.players-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.25rem;
  transition: opacity 0.15s;
}

.btn:active { opacity: 0.8; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-copy {
  background: var(--green);
  color: #fff;
}

/* ── Staged matches ──────────────────────────────────── */
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.match-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  font-size: 0.875rem;
  align-items: center;
}

.match-tag {
  background: var(--border);
  border-radius: 0.3rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.match-score { color: var(--subtext); }
.match-result { color: var(--green); font-weight: 600; }

.remove-btn {
  background: none;
  border: none;
  color: var(--subtext);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  flex-shrink: 0;
}

.remove-btn:hover { color: var(--red); }

.empty-msg { color: var(--subtext); font-size: 0.875rem; }

/* ── JSON output ─────────────────────────────────────── */
textarea#json-output {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  min-height: 180px;
  resize: vertical;
}

.json-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ── Nav link ────────────────────────────────────────── */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0.5rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

/* ── RTG: Player checkbox toggles ───────────────────────── */
.check-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.check-btn input[type="checkbox"] {
  display: none;
}

.check-btn label {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.check-btn input[type="checkbox"]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── RTG: Round cards ────────────────────────────────────── */
.round-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.round-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.sit-out {
  font-size: 0.8rem;
  color: var(--subtext);
  font-style: italic;
}

/* ── RTG: Match entry within a round card ───────────────── */
.match-entry {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.match-entry + .match-entry {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.match-label {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.score-input {
  width: 120px;
  max-width: 100%;
}

/* ── RTG: Bottom action row ─────────────────────────────── */
.rtg-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ── RTG: Validation error highlight ───────────────────── */
.input-error {
  outline: 2px solid var(--red) !important;
  outline-offset: 0;
}

/* ── Site footer ─────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  color: var(--subtext);
  font-size: 0.75rem;
  opacity: 0.6;
  line-height: 1.8;
}

.site-footer a {
  color: var(--subtext);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
}

.site-footer a:hover {
  border-bottom-color: var(--subtext);
  opacity: 1;
}
