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

:root {
  --green: #2d5a27;
  --green-light: #4a7c42;
  --cream: #f5f0e8;
  --gold: #c9a227;
  --text: #1a1a1a;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--cream);
  line-height: 1.6;
}

header {
  background: var(--green);
  color: white;
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

nav {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--gold);
}

.nav-view-link {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.footer-view-link {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
}

.footer-view-link:hover {
  text-decoration: underline;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

.section-intro {
  margin-bottom: 1rem;
}

.category-filter {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.category-filter label {
  font-weight: 600;
  color: var(--green);
}

.category-filter select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--green);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
  appearance: auto;
}

.category.hidden {
  display: none;
}

.category {
  background: white;
  border-radius: 8px;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--green);
}

.category h3 {
  color: var(--green);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.entry-list {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 0;
}

.entry-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.entry-list li:last-child {
  border-bottom: none;
}

.entry-list li[contenteditable="true"] {
  cursor: text;
  padding-left: 0.25rem;
  margin-left: -0.25rem;
  border-radius: 4px;
  outline: none;
}

.entry-list li[contenteditable="true"]:hover {
  background: rgba(45, 90, 39, 0.06);
}

.entry-list li[contenteditable="true"]:focus {
  background: rgba(45, 90, 39, 0.08);
}

.hero {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  color: white;
  border-radius: 12px;
  margin-bottom: 3rem;
  box-shadow: 0 4px 20px rgba(45, 90, 39, 0.3);
}

.hero h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.1em;
}

.hero-title-sponsor {
  margin: 0 auto 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: min(450px, 95vw);
}

.hero-title-sponsor img {
  display: block;
  max-height: 150px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.tagline {
  font-size: 1.25rem;
  opacity: 0.95;
  margin-bottom: 1rem;
}

.hero p:last-of-type {
  opacity: 0.9;
  font-size: 1rem;
}

.section {
  padding: 2rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.section:last-of-type {
  border-bottom: none;
}

.section h2 {
  color: var(--green);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.section p {
  color: var(--text);
  max-width: 65ch;
}

/* Partner logos (neutral paths/class names — ad blockers often hide #sponsors / sponsor* URLs) */
.partners-section {
  text-align: center;
}

.partners-section h2 {
  margin-bottom: 1.25rem;
}

.partners-box {
  background: #fff;
  color: var(--text);
  padding: 1.75rem 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.partners-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin: 0;
}

.partner-logo {
  flex: 0 0 auto;
  max-width: 180px;
}

.partner-logo img {
  max-height: 80px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

footer {
  text-align: center;
  padding: 2rem;
  background: var(--green);
  color: white;
  margin-top: 3rem;
  font-size: 0.9rem;
}

footer a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Run tournament page */
.hero-compact {
  padding: 2rem !important;
  margin-bottom: 1.5rem !important;
}

.hero-compact .tagline {
  margin-bottom: 0;
}

.run-tournament-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.run-tournament-filters .filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.run-tournament-filters label {
  font-weight: 600;
  color: var(--green);
}

.run-category-label {
  font-size: 1.1rem;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 1rem;
}

.groups-container {
  display: grid;
  gap: 1rem;
}

.group-card {
  background: white;
  border-radius: 8px;
  padding: 1rem 1.15rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--green);
}

.group-card.hidden {
  display: none;
}

.group-card h3 {
  color: var(--green);
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.group-card h4.schedule-heading {
  color: var(--green);
  font-size: 0.95rem;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

/* Standings table */
.group-standings-wrap {
  margin-bottom: 0.35rem;
  overflow-x: auto;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--cream);
  border-radius: 6px;
  overflow: hidden;
}

.standings-table th,
.standings-table td {
  padding: 0.3rem 0.45rem;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.standings-table th {
  background: var(--green);
  color: white;
  font-weight: 600;
}

.standings-legend {
  font-size: 0.78rem;
  color: #555;
  margin: 0 0 0.5rem;
  max-width: 65ch;
}

.standings-table th:nth-child(1) { width: 2.5rem; text-align: center; }
.standings-table th:nth-child(3),
.standings-table th:nth-child(4),
.standings-table th:nth-child(5),
.standings-table th:nth-child(6) { text-align: center; }
.standings-table th:nth-child(7) { width: 6rem; }

.standings-table td:nth-child(1) { text-align: center; font-weight: 600; color: var(--green); }
.standings-table td:nth-child(3),
.standings-table td:nth-child(4),
.standings-table td:nth-child(5),
.standings-table td:nth-child(6) { text-align: center; }

.standings-table td.qual-cell { text-align: center; }
.qualified-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  background: rgba(45, 90, 39, 0.12);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.qualified-badge-third {
  color: #6b4e00;
  background: rgba(201, 162, 39, 0.2);
}

.standings-table tbody tr:hover {
  background: rgba(45, 90, 39, 0.04);
}

/* Group schedule */
.group-schedule-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.group-schedule-match {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
}

.group-schedule-match:last-child {
  border-bottom: none;
}

.match-player {
  flex: 1;
  min-width: 5rem;
}

.match-score-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.match-score-input {
  width: 2.5rem;
  padding: 0.2rem 0.25rem;
  font-size: 0.85rem;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: white;
}

.match-score-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45, 90, 39, 0.2);
}

.match-score-sep {
  font-weight: 700;
  color: var(--green);
  font-size: 0.9rem;
}

.match-time-wrap {
  flex-shrink: 0;
  margin-left: 0.25rem;
}

.match-time-input {
  padding: 0.2rem 0.35rem;
  font-size: 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: white;
  min-width: 4.5rem;
}

.match-time-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45, 90, 39, 0.2);
}

.match-court-wrap {
  flex-shrink: 0;
  margin-left: 0.25rem;
}

.match-court-select {
  padding: 0.2rem 0.35rem;
  font-size: 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: white;
  min-width: 5.5rem;
  cursor: pointer;
}

.match-court-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45, 90, 39, 0.2);
}

.match-court-readonly {
  flex-shrink: 0;
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  margin-left: 0.25rem;
}

.match-vs {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 600;
  flex-shrink: 0;
}

.match-score {
  font-weight: 600;
  color: var(--text);
  margin-left: 0.5rem;
}

.group-player-list {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 0;
}

.group-player-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.group-player-list li:last-child {
  border-bottom: none;
}

/* Phase selector & panels */
.phase-selector {
  margin-bottom: 1.5rem;
}

.phase-selector label {
  font-weight: 600;
  color: var(--green);
  margin-right: 0.5rem;
}

.phase-selector select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--green);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.phase-panel {
  margin-top: 1rem;
}

.phase-panel.hidden {
  display: none;
}

.phase-panel h2 {
  margin-bottom: 1rem;
}

/* Knockout phase */
.knockout-intro {
  margin-bottom: 1.25rem;
  max-width: 65ch;
}

.knockout-bye-note {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.knockout-pending-note {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(201, 162, 39, 0.15);
  border-radius: 6px;
  font-size: 0.9rem;
  max-width: 65ch;
}

.knockout-bracket-note {
  font-size: 0.82rem;
  color: #444;
  max-width: 72ch;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.third-place-summary {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: white;
  border-radius: 8px;
  border-left: 4px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.third-place-summary h3 {
  margin-top: 0;
  color: var(--green);
  font-size: 1.1rem;
}

.third-place-help {
  font-size: 0.9rem;
  max-width: 65ch;
  margin-bottom: 0.75rem;
}

.third-place-pending {
  font-size: 0.9rem;
  color: #555;
  margin: 0;
}

.third-place-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.third-place-list li {
  margin-bottom: 0.35rem;
}

.third-tiebreak-box {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(201, 162, 39, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.35);
}

.third-tiebreak-box h4 {
  margin: 0 0 0.5rem;
  color: var(--green);
  font-size: 1rem;
}

.third-tiebreak-note,
.third-tiebreak-done {
  font-size: 0.88rem;
  margin: 0 0 0.75rem;
  max-width: 65ch;
}

.third-tiebreak-match {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.third-tiebreak-match:last-of-type {
  border-bottom: none;
}

.knockout-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.knockout-round {
  background: white;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--green);
}

.knockout-round-title {
  color: var(--green);
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.knockout-matches {
  display: grid;
  gap: 0.75rem;
}

.knockout-match {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.knockout-match:last-child {
  border-bottom: none;
}

.knockout-match-label {
  font-weight: 600;
  color: var(--text);
  min-width: 5rem;
}

.knockout-match-slots {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.knockout-slot {
  min-width: 8rem;
  padding: 0.35rem 0.5rem;
  background: var(--cream);
  border-radius: 4px;
  text-align: center;
  color: var(--text);
}

.knockout-vs {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 600;
}

.knockout-champion {
  padding: 0.5rem;
  background: rgba(201, 162, 39, 0.15);
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 600px) {
  nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero {
    padding: 3rem 1.5rem;
  }

  .hero h2 {
    font-size: 1.5rem;
  }
}

/* Tighter layout on smartphones for schedule & standings */
@media (max-width: 480px) {
  .group-card {
    padding: 0.75rem 0.9rem;
  }

  .group-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
  }

  .group-card h4.schedule-heading {
    margin-top: 0.6rem;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
  }

  .standings-table {
    font-size: 0.82rem;
  }

  .standings-table th,
  .standings-table td {
    padding: 0.25rem 0.35rem;
  }

  .group-schedule-match {
    padding: 0.22rem 0;
    gap: 0.25rem;
  }

  .match-player {
    font-size: 0.9rem;
  }

  .match-score-input {
    width: 2.25rem;
    padding: 0.18rem 0.2rem;
    font-size: 0.8rem;
  }

  .match-time-input {
    min-width: 4rem;
    font-size: 0.8rem;
    padding: 0.18rem 0.25rem;
  }

  .match-court-select {
    min-width: 5rem;
    font-size: 0.75rem;
    padding: 0.18rem 0.25rem;
  }

  .match-court-readonly {
    min-width: 4rem;
    font-size: 0.8rem;
  }

  .groups-container {
    gap: 0.75rem;
  }
}

/* Public read-only tournament view (run-tournament.html?view=1) */
.match-score-readonly {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 4rem;
  justify-content: center;
  font-weight: 600;
}

.match-time-readonly {
  font-variant-numeric: tabular-nums;
  min-width: 4.5rem;
  text-align: center;
  color: #444;
  font-size: 0.95rem;
}

.group-schedule-match--readonly,
.third-tiebreak-match--readonly {
  opacity: 0.98;
}

/* Cloud sync (admin + run tournament) */
.cloud-sync-panel {
  background: rgba(45, 90, 39, 0.06);
  border: 1px solid rgba(45, 90, 39, 0.2);
  border-radius: 8px;
}

.cloud-sync-help {
  font-size: 0.9rem;
  color: #444;
  margin-bottom: 0.75rem;
}

.cloud-sync-help code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.cloud-status-line {
  min-height: 1.4em;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 0.75rem;
}

.cloud-sync-actions label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.cloud-sync-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cloud-sync-row input[type="password"] {
  flex: 1;
  min-width: 10rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn-cloud {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: var(--green);
  color: white;
  cursor: pointer;
}

.btn-cloud:hover {
  background: var(--green-light);
}

.btn-cloud:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.view-mode .cloud-sync-panel {
  display: none !important;
}

body.view-mode .knockout-qf-admin-hint {
  display: none;
}

/* Admin: quarter-final label inputs */
.qf-labels-fields {
  margin-top: 1rem;
  max-width: 42rem;
}

.qf-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.85rem;
}

.qf-label-qi {
  min-width: 2.75rem;
  font-weight: 700;
  color: var(--green);
  font-size: 0.95rem;
}

.qf-label-row .qf-vs {
  font-weight: 600;
  color: var(--green);
  font-size: 0.85rem;
}

.qf-label-input {
  flex: 1;
  min-width: 10rem;
  padding: 0.45rem 0.55rem;
  font-size: 1rem;
  border: 2px solid rgba(45, 90, 39, 0.35);
  border-radius: 6px;
  background: white;
  color: var(--text);
}

.qf-label-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45, 90, 39, 0.2);
}
