:root {
  --bg: #0a1f18;
  --surface: #123528;
  --surface-2: #1a4535;
  --text: #f2f7f4;
  --muted: #9bb8ad;
  --accent: #3dd68c;
  --accent-dark: #2a9d63;
  --danger: #ff6b6b;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
}

.pill {
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  white-space: nowrap;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
}

.site-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.card-compact {
  padding: 14px 18px;
}

.card-bye {
  border-color: rgba(61, 214, 140, 0.25);
}

h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

h2 {
  margin: 0;
}

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.lead {
  color: var(--muted);
  margin: 0 0 18px;
}

.hint {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

.rankings-line {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea {
  min-height: 160px;
  resize: vertical;
  font-family: inherit;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #062015;
}

.btn-primary:active {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  list-style: none;
}

.alert-error {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffc9c9;
}

.match-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.match-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.versus {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
  text-align: center;
}

.player-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.vs {
  color: var(--muted);
  font-size: 0.9rem;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.score-field input {
  min-height: 52px;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}

.standings-list {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.standings-list li {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.standings-list .rank {
  font-weight: 700;
  color: var(--muted);
}

.standings-list .name {
  font-weight: 600;
}

.standings-list .pts {
  color: var(--accent);
  font-weight: 700;
}

.standings-list .games {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.standings-final li.top .rank,
.standings-final li.top .name {
  color: var(--accent);
}

.card-actions {
  padding: 14px 18px;
}

.card-actions .form {
  gap: 10px;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  text-align: center;
}

.bye-names {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  flex: 1;
  min-width: 4rem;
  justify-content: center;
  font-weight: 600;
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
}

.radio-option input {
  width: auto;
  min-height: auto;
  margin: 0;
}

fieldset.field {
  border: none;
  padding: 0;
  margin: 0;
}

.phase-hint {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.25);
  font-size: 0.9rem;
  color: var(--accent);
}

.competition-label {
  margin-top: 0;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.45;
}

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

.history-empty {
  color: var(--muted);
}

.shuttle-rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.shuttle-rain__item {
  position: absolute;
  top: -2rem;
  opacity: 0.85;
  line-height: 1;
  animation: shuttle-fall linear forwards;
  will-change: transform;
}

@keyframes shuttle-fall {
  to {
    transform: translateY(110vh) rotate(var(--shuttle-spin, 360deg));
  }
}

@media (prefers-reduced-motion: reduce) {
  .shuttle-rain {
    display: none;
  }
}

.text-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pairing-builder-card {
  margin-bottom: 14px;
}

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

.pairing-grid-singles {
  grid-template-columns: 1fr 1fr;
}

.player-select,
.swap-select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}

.swap-form {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.swap-field {
  display: block;
}

.swap-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.swap-row .swap-select {
  flex: 1;
}

.btn-sm {
  min-height: var(--tap);
  padding: 0 14px;
  white-space: nowrap;
  font-size: 0.9rem;
}
