:root {
  --navy: #0b1f3a;
  --bg: #eef1f5;
  --accent: #ffc400;
  --button: #f8c940;
  --muted: #4a5b72;
  --border: #9aabc0;
  --win: #1f9d55;
  --loss: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: "Barlow", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: 84px;
}

.app-header {
  background: var(--navy);
  color: #fff;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.app-title, .section-title, .rank-badge {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 800;
  text-transform: uppercase;
}
.app-title { margin: 0; font-size: 30px; line-height: 1; }
.app-subtitle { margin: 4px 0 0; color: #c9d4e3; font-size: 15px; }

.page { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  margin: 0 0 16px;
  box-shadow: 0 1px 2px rgb(11 31 58 / 8%);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 12px;
  font-size: 24px;
  color: var(--navy);
}
.count { font-family: "Barlow Condensed", sans-serif; font-weight: 800; color: var(--muted); }
.muted { color: var(--muted); }
p { margin: 0 0 4px; }

.flash { background: #fff7d6; border-radius: 12px; padding: 10px 14px; margin: 0 0 16px; }
.flash-error { background: #fde8e6; color: #7a1f16; }

.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard-row, .own-position-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.leaderboard-row + .leaderboard-row { border-top: 1px solid var(--bg); }
.leaderboard-main { flex: 1; min-width: 0; }
.player-name { font-weight: 600; margin: 0; }
.rating { font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 28px; margin: 0; margin-left: auto; }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg); font-size: 20px; flex: none;
}
.rank-first { background: var(--accent); }
.own-position .own-position-body > div { flex: 1; }

.form-dots { display: flex; gap: 4px; margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-win { background: var(--win); }
.dot-loss { background: var(--loss); }

.month { margin-bottom: 8px; }
.month summary {
  display: flex; justify-content: space-between; cursor: pointer;
  font-family: "Barlow Condensed", sans-serif; font-weight: 800;
  text-transform: uppercase; font-size: 22px; padding: 8px 0;
}
.match-meta { font-size: 15px; }
.team-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.team-winner .team-names { font-weight: 600; }
.set-scores { display: flex; gap: 6px; }
.set {
  min-width: 30px; text-align: center; border-radius: 8px; padding: 0 6px;
  font-weight: 600; color: var(--muted);
}
.set-won { background: var(--accent); color: var(--navy); }
.match-note { font-size: 15px; margin-top: 6px; }
.match-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.chip { background: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 14px; font-weight: 600; }
.edit-link { margin-left: auto; color: var(--navy); font-weight: 600; }

.field { margin-bottom: 14px; }
.field label, .sets legend { display: block; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 8px 12px;
  border: 2px solid var(--border); border-radius: 14px;
  font: inherit; color: var(--navy); background: #fff;
}
textarea { min-height: 96px; }
.sets { border: 0; padding: 0; margin: 0 0 14px; }
.sets-grid { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 8px; align-items: center; }
.set-label { font-weight: 600; }
.field-error { display: block; color: var(--loss); }
.winner-line, .audit-line { margin: 8px 0 14px; }
.button {
  width: 100%; min-height: 48px; border: 0; border-radius: 12px;
  background: var(--button); color: var(--navy); font: inherit; font-weight: 600; cursor: pointer;
}
.link-button { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.telegram-widget { margin-top: 16px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--navy); display: flex; justify-content: space-around;
  padding: 12px 8px calc(12px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  color: #fff; text-decoration: none; font-family: "Barlow Condensed", sans-serif;
  font-weight: 800; text-transform: uppercase; font-size: 18px; padding: 4px 16px;
}
.bottom-nav a.active { color: var(--accent); }
