:root {
  --bg: #faf8f2;
  --card: #ffffff;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --muted: #9ca3af;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --good: #16a34a;
  --warm: #d97706;
  --soft: #f3f4f6;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body { padding: 0 16px 64px 16px; max-width: 640px; margin: 0 auto; }

h1 { font-size: 1.6rem; margin: 16px 0 8px 0; }
h2 { font-size: 1.2rem; margin: 24px 0 8px 0; }
h3 { font-size: 1.05rem; margin: 16px 0 4px 0; }

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

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 8px rgba(0,0,0,0.04);
}

.big-card {
  background: var(--accent);
  color: white;
  border-radius: 14px;
  padding: 22px;
  margin: 12px 0;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.big-card .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.big-card .station { font-size: 1.8rem; font-weight: 700; line-height: 1.1; margin: 6px 0; }
.big-card .when { font-size: 1rem; opacity: 0.9; }
.big-card .metric { margin-top: 10px; font-size: 0.95rem; opacity: 0.9; }

.next-card { background: var(--soft); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 12px 0; }
.next-card .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.next-card .station { font-weight: 600; font-size: 1.1rem; }

.button, button.primary {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: center;
}
.button:hover, button.primary:hover { background: var(--accent-dark); }

button.secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

button.danger {
  background: white;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.team-grid button {
  background: white;
  border: 1px solid var(--border);
  padding: 18px 10px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 64px;
}

.team-grid button.selected { background: var(--accent); color: white; border-color: var(--accent); }

input, select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

label { display: block; margin: 14px 0 6px 0; font-size: 0.9rem; font-weight: 600; }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--soft); font-weight: 600; }

.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); }
.lb-row .rank { width: 28px; height: 28px; border-radius: 14px; background: var(--soft); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; }
.lb-row .name { flex: 1; font-weight: 600; }
.lb-row .total { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.lb-row.first .rank { background: #fde68a; color: #92400e; }
.lb-row.second .rank { background: #d1d5db; color: #1f2937; }
.lb-row.third .rank { background: #fed7aa; color: #9a3412; }

.pill {
  display: inline-block;
  background: var(--soft);
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.pill.live { background: #dcfce7; color: var(--good); }
.pill.warn { background: #fef3c7; color: var(--warm); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.toast.show { opacity: 1; }

.center { text-align: center; }
.spacer { height: 16px; }

a { color: var(--accent); }
a:visited { color: var(--accent-dark); }

.error { color: #b91c1c; font-size: 0.9rem; margin: 8px 0; }
.success { color: var(--good); font-size: 0.9rem; margin: 8px 0; }

.station-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.station-row:last-child { border-bottom: none; }
.station-row .num { width: 26px; height: 26px; background: var(--soft); border-radius: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; }
.station-row .name { flex: 1; }
.station-row .when { color: var(--muted); font-size: 0.85rem; }

.hidden { display: none !important; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 28px; }
