:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-strong: #eef5ed;
  --text: #18211c;
  --muted: #69756d;
  --line: #dbe4dc;
  --primary: #13795b;
  --primary-dark: #0d5e46;
  --a-team: #e6f1ff;
  --a-team-line: #b6d7ff;
  --b-team: #fff1e4;
  --b-team-line: #ffd1a6;
  --danger: #b3261e;
  --shadow: 0 12px 28px rgba(26, 39, 31, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.icon-button,
.text-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.text-button {
  color: var(--primary-dark);
}

.add-player {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(19, 121, 91, 0.16);
}

.add-player button,
.primary-action {
  min-height: 46px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.player-chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 800;
}

.team-grid {
  display: grid;
  gap: 10px;
}

.team-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.team-a {
  background: var(--a-team);
  border-color: var(--a-team-line);
}

.team-b {
  background: var(--b-team);
  border-color: var(--b-team-line);
}

.team-header {
  display: grid;
  grid-template-columns: 1fr 94px;
  align-items: center;
  gap: 10px;
}

.team-header strong {
  font-size: 18px;
}

.team-header input {
  min-height: 42px;
  text-align: center;
  font-weight: 900;
}

.versus {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.quick-score {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.quick-score button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.primary-action {
  width: 100%;
  font-size: 17px;
}

.form-message {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 6px 0 14px;
  padding: 8px 0;
  background: rgba(245, 247, 243, 0.92);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

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

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.empty-state {
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
}

.match-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.match-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.match-team {
  min-width: 0;
  font-weight: 800;
}

.match-team.right {
  text-align: right;
}

.winner {
  color: var(--primary-dark);
}

.score {
  min-width: 74px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.match-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.delete-match {
  background: transparent;
  color: var(--danger);
  font-weight: 800;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.partner-list {
  display: grid;
  gap: 10px;
}

.partner-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.partner-card strong {
  display: block;
  margin-bottom: 4px;
}

.partner-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.partner-rate {
  color: var(--primary-dark);
  font-size: 20px;
  font-weight: 900;
}

@media (min-width: 620px) {
  .team-grid {
    grid-template-columns: 1fr 42px 1fr;
    align-items: center;
  }
}
