:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #15171a;
  --muted: #666f7a;
  --border: #d9dee5;
  --accent: #1769e0;
  --accent-strong: #0d4fb5;
  --danger: #b42318;
  --success: #087443;
  --warning: #8a6100;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 25, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
}

input,
button,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem max(1rem, calc((100vw - 1120px) / 2));
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 0.35rem;
}

.nav a {
  padding: 0.55rem 0.7rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
  border-radius: 7px;
}

.nav a:hover {
  background: #edf2f8;
  color: var(--text);
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.75rem, 6vw, 3.2rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0.8rem;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.muted,
.hero-row p {
  color: var(--muted);
}

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 0 1.5rem;
}

.hero-row.compact h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

.section,
.empty-state {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section.narrow,
.empty-state {
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.95rem;
  color: #fff;
  font-weight: 750;
  text-decoration: none;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  color: var(--text);
  background: #e9eef5;
}

.button.secondary:hover {
  background: #dce4ee;
}

.button.danger {
  background: var(--danger);
}

.messages {
  display: grid;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.message {
  padding: 0.75rem 0.9rem;
  background: #eef4ff;
  border: 1px solid #cdddf8;
  border-radius: var(--radius);
}

.message-error {
  background: #fff0ee;
  border-color: #ffd1cc;
}

.message-success {
  background: #ecfdf3;
  border-color: #b8ebc9;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.match-card,
.result-card,
.admin-match {
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.match-card.is-highlighted {
  border-color: #9bbff2;
  background: #f1f6ff;
}

.match-meta,
.result-card header,
.admin-match header,
.round header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.match-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  margin: 0.65rem 0;
  font-size: 1.05rem;
}

.match-teams span:last-child {
  text-align: right;
}

.match-teams strong,
.score-large {
  font-size: 1.65rem;
  line-height: 1;
}

.status {
  display: inline-flex;
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 760;
  border-radius: 999px;
}

.status.done {
  color: var(--success);
  background: #e6f6ed;
}

.status.open {
  color: var(--warning);
  background: #fff5db;
}

.table-wrap {
  overflow-x: auto;
}

.standings-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.standings-table th,
.standings-table td {
  padding: 0.7rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.standings-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.team-cell {
  font-weight: 750;
}

.round-list {
  display: grid;
  gap: 0.9rem;
}

.round {
  padding-top: 0.3rem;
}

.round > header {
  align-items: baseline;
  padding-bottom: 0.5rem;
}

.team-select-list {
  display: grid;
  gap: 0.65rem;
}

.team-select-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 56px;
  padding: 0.8rem;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.team-select-item span {
  display: grid;
  width: 2.3rem;
  height: 2.3rem;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: var(--text);
  border-radius: 7px;
}

.result-list,
.admin-match-list {
  display: grid;
  gap: 0.75rem;
}

.score-form,
.admin-score-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
}

.score-form label,
.admin-score-form label,
.panel-form p {
  display: grid;
  gap: 0.35rem;
}

.score-form span,
.admin-score-form span,
.panel-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.score-form input,
.admin-score-form input,
.panel-form input,
.panel-form select {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.score-form input,
.admin-score-form input[type="number"] {
  font-size: 1.2rem;
  font-weight: 750;
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  min-height: 44px;
}

.checkbox-label input {
  width: 1.15rem;
  min-height: auto;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.panel-form {
  display: grid;
  gap: 0.75rem;
}

.errorlist {
  margin: 0 0 0.4rem;
  padding-left: 1.1rem;
  color: var(--danger);
}

@media (max-width: 720px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav {
    width: 100%;
  }

  .nav a {
    flex: 1;
    text-align: center;
  }

  .hero-row {
    align-items: stretch;
    flex-direction: column;
  }

  .match-grid,
  .score-form,
  .admin-score-form {
    grid-template-columns: 1fr;
  }

  .section,
  .empty-state {
    padding: 0.85rem;
  }

  .match-teams {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .match-teams span:last-child,
  .match-teams strong {
    text-align: left;
  }
}
