:root {
  --green: #1a7d3f;
  --green-dark: #145c30;
  --red: #b3261e;
  --bg: #f6f7f5;
  --card-bg: #ffffff;
  --border: #dfe3df;
  --text: #1c1f1c;
  --muted: #6b746c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.5rem;
  background: var(--green);
  color: white;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.topbar .brand {
  color: white;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar nav a, .topbar .who {
  color: white;
  text-decoration: none;
  font-size: 0.95rem;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.topbar nav a:hover { text-decoration: underline; }

.badge {
  background: rgba(255,255,255,0.25);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card.narrow {
  max-width: 420px;
  margin: 2rem auto;
}

h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

form label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

form input[type="text"], form input[type="password"], form select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

button, .button {
  display: inline-block;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button.primary, .button.primary {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
button.primary:hover { background: var(--green-dark); }

button.danger {
  background: white;
  border-color: var(--red);
  color: var(--red);
}
button.danger:hover { background: #fdecea; }

button.small, .button.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.link-button {
  background: none;
  border: none;
  color: white;
  text-decoration: underline;
  padding: 0;
  font-size: 0.95rem;
  cursor: pointer;
}

.inline-form { display: inline-block; margin: 0; }

.flash {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.1rem;
  font-size: 0.92rem;
}
.flash-success { background: #e6f4ea; color: var(--green-dark); border: 1px solid #b8e0c4; }
.flash-error { background: #fdecea; color: var(--red); border: 1px solid #f3b9b4; }

.status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-pending { background: #fff3cd; color: #7a5c00; }
.status-active { background: #d7ecff; color: #0b5394; }
.status-completed { background: #e6f4ea; color: var(--green-dark); }

.tournament-list { display: grid; gap: 0.9rem; }
.tournament-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}
.tournament-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.tournament-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.tournament-card-top h2 { margin: 0; }
.tournament-card .subtitle { margin-top: 0.35rem; }

.chip {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.chip-friendly { background: #eef2ff; color: #3b4b9c; }

.champion-banner {
  font-size: 1.1rem;
  text-align: center;
  background: #fff8e1;
  border-color: #f3d98a;
}

.danger-zone {
  border-color: #f3b9b4;
  margin-top: 1.5rem;
}
.danger-zone h2 { color: var(--red); }

.player-list { padding-left: 1.2rem; margin: 0.5rem 0; }
.player-list li { margin-bottom: 0.2rem; }

.match-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }

.bracket-section { margin-bottom: 2rem; }
.bracket-rounds {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.bracket-round {
  min-width: 220px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.match-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
}
.match-card.status-confirmed { border-color: #b8e0c4; }
.match-card.status-reported { border-color: #f3d98a; }
.match-card.status-bye, .match-card.status-double_bye { opacity: 0.7; }

.player-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 0;
  font-size: 0.92rem;
}
.player-line.winner { font-weight: 700; }
.trophy { font-size: 0.8rem; }

.match-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; }
.match-empty { font-size: 0.82rem; padding: 0.3rem 0; }

.report-form { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.radio-row { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.82rem; font-weight: 400; }
.radio-row label { display: flex; align-items: center; gap: 0.35rem; font-weight: 400; margin: 0; }
.report-form input[type="text"], .report-form input[type="password"] { font-size: 0.85rem; padding: 0.4rem 0.5rem; }
.reset-password-details { margin-top: 0.5rem; }

/* score-report: set-count picker + per-set scoreboard grid */
.score-report { margin-top: 0.6rem; }
.score-report .sets-select-row label { font-size: 0.82rem; margin-bottom: 0; }
.score-report .sets-select-row select { font-size: 0.85rem; padding: 0.4rem 0.5rem; margin-top: 0.25rem; }

.scoreboard-wrap { position: relative; margin-top: 0.7rem; overflow-x: auto; padding-bottom: 0.15rem; }
.scoreboard-grid { display: grid; align-items: center; gap: 0.35rem 0.4rem; min-width: max-content; }
.set-head {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pname { font-weight: 700; font-size: 0.8rem; white-space: nowrap; padding-right: 0.25rem; }
.score-cell input[type="number"] {
  width: 2.3rem;
  padding: 0.3rem 0.15rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  -moz-appearance: textfield;
}
.score-cell input[type="number"]::-webkit-outer-spin-button,
.score-cell input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

.winner-summary {
  margin-top: 0.7rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  text-align: center;
  color: var(--muted);
}
.winner-summary.decided {
  background: #e6f4ea;
  border-color: #b8e0c4;
  color: var(--green-dark);
  font-weight: 700;
}

.admin-override { margin-top: 0.6rem; }
.admin-override summary { cursor: pointer; font-size: 0.78rem; color: var(--muted); }

.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.standings-table tr.me-row { background: #f0f7f2; }

.solo-match-row { margin-bottom: 0.9rem; }
.solo-match-row:last-child { margin-bottom: 0; }

/* Avatars: a plain square photo or an initials circle, made round with
   border-radius wherever it's shown. */
.avatar {
  display: inline-flex;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  vertical-align: middle;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.player-name { display: inline-flex; align-items: center; gap: 0.4rem; }
.player-name a { color: inherit; text-decoration: none; }
.player-name a:hover { text-decoration: underline; }

.standings-player {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}
.standings-player:hover { text-decoration: underline; }

/* Home page: profile block, next-match block, activity feed */
.home-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr 1fr;
}
.home-profile {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.home-profile h1 { margin: 0 0 0.6rem; font-size: 1.9rem; }
.home-stats { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.next-match-opponent {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.next-match-vs { font-weight: 700; }

.home-activity .activity-feed {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.5rem;
}
.activity-row { padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; padding-bottom: 0; }
.home-activity-more { margin-top: 0.75rem; margin-bottom: 0; }

.player-header { display: flex; align-items: center; gap: 1.25rem; }

/* Tennis session attendance checklists (record / edit) */
.attendee-checklist {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-top: 0.4rem;
}
.attendee-check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

/* Tournament requests: the list on the Tournaments tab, and the admin
   notice card on Home */
.request-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.request-row:last-child { border-bottom: none; padding-bottom: 0; }
.home-request-alert {
  border-color: #f3d98a;
  background: #fff8e1;
}

/* Deleted (deactivated) user accounts on the Users page */
.inactive-row { opacity: 0.6; }
.badge-inactive {
  background: #fdecea;
  color: var(--red);
}

/* Account page sections */
.account-section { margin-top: 1.5rem; }
.account-section:first-of-type { margin-top: 0; }
.account-avatar-row { display: flex; align-items: center; gap: 1.25rem; margin: 0.75rem 0; }
.account-avatar-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

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

@media (max-width: 600px) {
  .container { padding: 1rem; }
  .bracket-rounds { gap: 1rem; }
  .bracket-round { min-width: 180px; }
}
