:root {
  --bg: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #F4F4F4;
  --line: #E4E4E4;
  --text: #1A1A1A;
  --text-dim: #5C5C5C;
  --text-faint: #8C8C8C;
  --accent: #B8860B;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(184, 134, 11, 0.10);
  --success: #1F7A4D;
  --success-soft: rgba(31, 122, 77, 0.10);
  --loss: #A63E2C;
  --loss-soft: rgba(166, 62, 44, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.note { font-size: 12.5px; color: var(--text-faint); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.loading-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-family: var(--font-display); font-size: 18px; color: var(--text-dim);
}

#app { max-width: 880px; margin: 0 auto; padding: 0 20px 60px; }

/* ---------- Header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-family: var(--font-num); font-weight: 700; font-size: 22px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand-tag { font-size: 12px; color: var(--text-faint); }

.tabs { display: flex; gap: 6px; background: var(--panel-2); padding: 4px; border-radius: var(--radius-sm); }
.tab-btn {
  font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 16px; border-radius: 6px; cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: var(--accent-ink); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ---------- Layout / views ---------- */
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.section-head h2 { font-family: var(--font-display); font-size: 20px; margin: 0; font-weight: 700; }
.back-btn {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-size: 13px; padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  margin-bottom: 20px;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.intro-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 28px; margin-bottom: 32px; box-shadow: var(--shadow);
}
.intro-card h1 {
  font-family: var(--font-display); font-size: 30px; font-weight: 800;
  margin: 0 0 10px; letter-spacing: -0.01em; text-wrap: balance;
}
.intro-card p { margin: 0; color: var(--text-dim); max-width: 60ch; }

/* ---------- League grid ---------- */
.league-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.league-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .15s ease, transform .15s ease;
  display: flex; flex-direction: column; gap: 6px;
}
.league-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.league-card .name { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.league-card .meta { font-size: 12px; color: var(--text-faint); }
.empty { color: var(--text-faint); font-size: 14px; padding: 20px 0; }

/* ---------- Leaderboard ---------- */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: grid; grid-template-columns: 34px 1fr auto 70px; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; transition: border-color .15s ease;
}
.rank-row:hover { border-color: var(--accent); }
.rank-row.leader { background: linear-gradient(90deg, var(--accent-soft), var(--panel) 65%); border-color: var(--accent); }
.rank-badge {
  width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 13px; color: var(--text-dim);
}
.rank-row.leader .rank-badge { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rank-name { display: flex; flex-direction: column; min-width: 0; }
.rank-name .n { font-weight: 600; font-size: 14.5px; }
.rank-name .t { font-size: 12px; color: var(--text-faint); }
.prov-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  color: var(--text-faint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 6px;
}
.rank-trend {
  font-family: var(--font-num); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; min-width: 24px;
}
.rank-trend.up { color: var(--success); }
.rank-trend.down { color: var(--loss); }
.rank-rating {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 6px 4px;
}
.rank-rating .n { font-family: var(--font-num); font-weight: 700; font-size: 18px; color: var(--accent); line-height: 1; }
.rank-rating .l { font-size: 8.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-top: 3px; }
@media (max-width: 640px) {
  .rank-row { grid-template-columns: 28px 1fr auto 60px; row-gap: 6px; }
}

/* ---------- Player profile ---------- */
.player-head {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.player-head .rating-big { font-family: var(--font-num); font-weight: 700; font-size: 40px; color: var(--accent); line-height: 1; }
.player-head .rating-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-top: 4px; }
.player-head .rating-block { display: flex; flex-direction: column; align-items: center; }
.player-head .id-block h2 { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }
.player-head .id-block .sub { color: var(--text-faint); font-size: 13px; }
.player-head .stat-strip { display: flex; gap: 22px; margin-left: auto; }
.player-head .stat-strip .stat { display: flex; flex-direction: column; align-items: center; }
.player-head .stat-strip .v { font-family: var(--font-num); font-weight: 700; font-size: 17px; }
.player-head .stat-strip .l { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

.other-leagues { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.other-league-chip {
  font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; color: var(--text-dim);
}
.other-league-chip:hover { border-color: var(--accent); color: var(--accent); }

.history-row {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.history-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.result-badge {
  width: 24px; height: 24px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: var(--font-num);
}
.result-badge.w { background: var(--success); }
.result-badge.l { background: var(--loss); }
.result-badge.d { background: var(--text-faint); }
.history-detail { min-width: 0; }
.history-detail .label { font-weight: 600; font-size: 13.5px; }
.history-detail .sub { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.rating-delta { font-family: var(--font-num); font-weight: 700; font-size: 14px; flex-shrink: 0; }
.rating-delta.up { color: var(--success); }
.rating-delta.down { color: var(--loss); }

/* ---------- Predictions ---------- */
.predict-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.predict-league { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; margin-bottom: 10px; font-family: var(--font-display); }
.predict-sides { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.predict-side { flex: 1; text-align: center; font-weight: 600; font-size: 14.5px; }
.predict-vs { color: var(--text-faint); font-family: var(--font-display); font-size: 12px; text-transform: uppercase; }
.predict-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--panel-2); margin-top: 14px; }
.predict-bar .a { background: var(--accent); }
.predict-bar .b { background: var(--text-faint); }
.predict-pcts { display: flex; justify-content: space-between; font-family: var(--font-num); font-size: 12px; color: var(--text-dim); margin-top: 5px; }
.predict-meta { font-size: 12px; color: var(--text-faint); margin-top: 10px; }
.predict-note { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Register wizard ---------- */
.wizard-step { max-width: 480px; }
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; position: relative; }
.field-group-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.text-input {
  font-family: var(--font-body); font-size: 15px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; width: 100%;
}
.text-input:focus { border-color: var(--accent); }
.suggestions { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.suggestion-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; cursor: pointer; text-align: left; font-family: var(--font-body);
}
.suggestion-item:hover { border-color: var(--accent); }
.suggestion-item .s-name { font-weight: 600; font-size: 13.5px; }
.suggestion-item .s-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-num); }

.field-optional { font-weight: 400; color: var(--text-faint); text-transform: none; letter-spacing: 0; }

/* Scorecard grid — mirrors the main Team Padel app's score-entry modal:
   one row per side, one column per set, plain numeric cells, a "won"
   highlight, and a 3rd column that only appears once sets 1+2 split 1-1. */
.score-table { display: grid; gap: 10px 8px; align-items: center; margin-bottom: 10px; }
.score-th { font-family: var(--font-display); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); text-align: center; }
.score-team-cell { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.score-cell-input {
  width: 100%; aspect-ratio: 1; min-height: 44px; text-align: center;
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); padding: 0;
}
.score-cell-input:focus { border-color: var(--accent); outline: none; }
.score-cell-input.tb { border-color: rgba(166, 62, 44, .35); }
.score-cell-input.tb:focus { border-color: var(--loss); }
.score-cell-input.won { background: var(--success-soft); border-color: var(--success); }
.score-cell-input.won.tb { background: var(--loss-soft); }
.score-row-divider { border-top: 1px dashed var(--line); margin: 2px 0; }
.score-warnings { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.score-warnings .warn { color: var(--loss); font-size: 12px; }
#reg-decider-toggle { margin-bottom: 10px; }
.score-sep { color: var(--text-faint); }

.form-error { color: var(--loss); font-size: 13px; min-height: 18px; margin: 4px 0 6px; }

.wizard-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.primary-btn {
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  background: var(--accent); color: var(--accent-ink); border: none;
  padding: 11px 22px; border-radius: var(--radius-sm); cursor: pointer;
}
.primary-btn:hover { opacity: 0.9; }
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.secondary-btn {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  background: none; color: var(--text-dim); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer;
}
.secondary-btn:hover { border-color: var(--accent); color: var(--accent); }

.screenshot-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.screenshot-upload .note { flex: 1; min-width: 160px; }

.wizard-progress { display: flex; gap: 6px; margin-bottom: 16px; }
.progress-dot { width: 22px; height: 4px; border-radius: 2px; background: var(--line); }
.progress-dot.done { background: var(--accent); opacity: 0.5; }
.progress-dot.current { background: var(--accent); }

.reg-done-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 32px; display: flex; flex-direction: column; align-items: center;
  gap: 4px; max-width: 360px; text-align: center;
}
.reg-done-rating { font-family: var(--font-num); font-weight: 700; font-size: 48px; color: var(--accent); line-height: 1; }
.reg-done-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: 12px; }
.reg-done-card p { margin: 0 0 20px; font-weight: 600; font-size: 16px; }

/* ---------- Passcode gate ---------- */
.gate-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; padding: 20px; background: var(--bg);
}
.gate-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: 340px; width: 100%; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 36px 28px; box-shadow: var(--shadow);
}
.gate-card h1 { font-family: var(--font-display); font-size: 22px; margin: 4px 0 0; }
.gate-card p { margin: 0; color: var(--text-dim); font-size: 14px; }
.gate-card .text-input { text-align: center; margin-top: 8px; }
.gate-card .primary-btn { width: 100%; margin-top: 4px; }

/* ---------- Admin ---------- */
.admin-record-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.admin-record {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13.5px;
}
.admin-record .n { font-weight: 600; }
.admin-record .t { color: var(--text-faint); font-size: 12px; }
.admin-suggestion-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.admin-search-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 6px; cursor: pointer;
}
.admin-search-row:hover { border-color: var(--accent); }
.admin-search-row .n { font-weight: 600; font-size: 13.5px; }
.admin-search-row .t { color: var(--text-faint); font-size: 12px; }
#admin-search-combine { margin-top: 14px; }

/* ---------- Admin: matchup predictor ---------- */
.matchup-picker { display: flex; align-items: flex-start; gap: 14px; }
.matchup-side { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.matchup-side-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--accent); font-family: var(--font-display);
}
.matchup-vs { color: var(--text-faint); font-family: var(--font-display); font-size: 12px; text-transform: uppercase; padding-top: 26px; }
.matchup-slot { position: relative; }
.matchup-picked {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13.5px;
}
.matchup-picked .n { font-weight: 600; }
.matchup-picked .t { color: var(--text-faint); font-size: 12px; }
.link-btn {
  background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 0; margin-left: auto;
}
.matchup-slot-results { position: relative; }
.matchup-slot-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-top: 6px; cursor: pointer; font-size: 13px;
  display: flex; flex-direction: column; gap: 1px;
}
.matchup-slot-row:hover { border-color: var(--accent); }
.matchup-slot-row .t { color: var(--text-faint); font-size: 11.5px; }
@media (max-width: 640px) {
  .matchup-picker { flex-direction: column; }
  .matchup-vs { padding-top: 0; }
}

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--text-faint); font-size: 12px; padding: 30px 0 10px; }
