:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --border: #e2e8e4;
  --text: #1c2620;
  --text-muted: #62726a;
  --primary: #2e8b57;
  --primary-dark: #226b43;
  --accent: #ffb703;
  --accent-dark: #e0a002;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 40, 30, 0.08), 0 1px 2px rgba(20, 40, 30, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .brand {
  font-family: 'Poppins', 'Inter', sans-serif;
}

a { color: var(--primary-dark); }

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--primary-dark);
}

.brand-ball { font-size: 1.3rem; }

.site-nav {
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.site-nav a:hover { background: var(--bg); }

.site-nav a.active {
  background: var(--primary);
  color: #fff;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

h1 { font-size: 1.6rem; margin: 0.2rem 0; }

.subtle { color: var(--text-muted); margin-top: 0; }

.section-heading {
  margin-top: 2rem;
  font-size: 1.2rem;
  color: var(--primary-dark);
}

.empty-note {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--text-muted);
  text-align: center;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.05s, background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent {
  background: var(--accent);
  color: #3a2a00;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-danger-outline {
  color: var(--danger);
  border-color: #f0c9c9;
}
.btn-danger-outline:hover { background: #fdf1f1; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

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

.inline-form input[type="text"],
.inline-form input[type="number"],
.setup-row input[type="number"] {
  font-family: inherit;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  min-width: 0;
}

select {
  font-family: inherit;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  background: #fff;
}

/* People page */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
}

.slot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slot-card.empty { border-style: dashed; opacity: 0.85; }

.slot-index {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.slot-card .inline-form { flex-wrap: wrap; }
.slot-card input[type="text"] { flex: 1; }

.save-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 60px;
}
.save-indicator.saved { color: var(--primary-dark); font-weight: 600; }
.save-indicator.error { color: var(--danger); font-weight: 600; }

/* Teams page */
.setup-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.setup-row label { font-weight: 600; font-size: 0.9rem; }

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.team-name-form input { font-weight: 700; flex: 1; }

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.unassigned-list { max-width: 420px; }

/* Bracket page */
.bracket-scroll {
  overflow-x: auto;
  padding-bottom: 1rem;
}

.bracket-canvas {
  position: relative;
}

.round-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bx-round-label {
  position: absolute;
  top: 0;
  text-align: center;
}

.bx-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.bx-connector {
  stroke: #cbd8d0;
  stroke-width: 2;
}

.bx-match {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 1;
}

.bx-match.decided { border-color: var(--primary); }

.match-team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 500;
}

.match-team.pending { color: var(--text-muted); font-style: italic; }
.match-team.placeholder { color: var(--text-muted); font-style: italic; }
.match-team.winner { background: #e4f4ea; color: var(--primary-dark); font-weight: 700; }
.match-team .score { font-weight: 700; }

.match-result-form {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.score-input { width: 55px; padding: 0.3rem; border-radius: 6px; border: 1px solid var(--border); }

.match-result-form select { flex: 1; min-width: 90px; }

/* Exciting reveal overlay */
.excite-overlay {
  position: fixed;
  inset: 0;
  background: #14201a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.excite-overlay.hidden { display: none; }

.excite-content {
  text-align: center;
  color: #fff;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
}

.excite-content h2 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  color: #d7e6dd;
}

.excite-card {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  padding: 1.5rem;
}

.excite-card.unrevealed {
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.excite-card.unrevealed:hover { border-color: var(--accent); }
.excite-card.unrevealed:active { transform: scale(0.98); }

.excite-click-prompt {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.excite-card.reveal {
  border-style: solid;
  border-color: var(--accent);
  animation: pop 0.35s ease;
}

.excite-card.done {
  border-style: solid;
  border-color: var(--primary);
}

.excite-done-msg {
  font-size: 1.2rem;
  color: #d7e6dd;
}

.excite-team-name {
  font-family: 'Poppins', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
}

.excite-team-players {
  font-size: 1.1rem;
  margin-top: 0.5rem;
  color: #d7e6dd;
}

.excite-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.hidden { display: none !important; }

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Mobile */
@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .page-title-row { flex-direction: column; align-items: flex-start; }
  .setup-row { flex-direction: column; align-items: stretch; }
  .card-grid, .teams-grid { grid-template-columns: 1fr; }
}
