:root {
  --bg: #f7f4ec;
  --card: #ffffff;
  --ink: #1e2a22;
  --muted: #6a6e69;
  --accent: #0b3d2e;
  --accent-light: #1d6b51;
  --warn: #b34a2a;
  --success: #2e7a4a;
  --border: #e3ddc9;
}

* { box-sizing: border-box; }

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

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
}
.topbar .brand { color: #fff; text-decoration: none; font-weight: 600; }
.who-form { margin: 0; }
.topbar .who {
  background: transparent;
  border: none;
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  opacity: 0.9;
  padding: 0.25rem 0.5rem;
  margin: 0;
  min-height: 0;
  cursor: pointer;
  border-radius: 4px;
}
.topbar .who:hover, .topbar .who:focus { background: rgba(255,255,255,0.12); opacity: 1; }

.footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer a { color: var(--muted); }

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

.banner {
  background: #fff5d9;
  border: 1px solid #e5d18b;
  padding: 0.75rem;
  border-radius: 6px;
  margin: 0 0 1rem;
}
.banner-warn { background: #fde2d6; border-color: #e9a081; }
.banner-success { background: #d8f0e0; border-color: #8acba0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 0 0 1rem;
}

.current-card { border-color: var(--accent-light); }
.card-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-light);
  margin-bottom: 0.25rem;
}

.btn-primary, .btn-secondary, .btn-warn, button {
  font: inherit;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-warn {
  background: var(--warn);
  color: #fff;
}
.link-button {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 0.5rem;
  min-height: auto;
}

.score-form, .claim-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}
.score-form label, .claim-form label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  gap: 0.25rem;
}
input[type="text"], input[type="number"], input[type="password"], input:not([type]) {
  font: inherit;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  min-height: 44px;
}
input:focus {
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
}

.team-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.team-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.team-row.taken { opacity: 0.7; }
.team-num {
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.team-name { font-weight: 600; flex: 1; }
.team-status { color: var(--muted); font-size: 0.85rem; }
.claim-form {
  flex: 1;
  flex-direction: row;
  margin: 0;
  align-items: stretch;
}
.claim-form input { flex: 1; }

.schedule {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.schedule li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
}
.schedule li.current { background: #eaf4ee; border: 1px solid var(--accent-light); }
.schedule li.done { color: var(--muted); }
.schedule-num {
  background: var(--border);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.schedule li.current .schedule-num { background: var(--accent); color: #fff; }
.schedule li.done .schedule-num { background: var(--success); color: #fff; }
.schedule a { color: inherit; text-decoration: none; flex: 1; }
.check { color: var(--success); font-weight: 700; }

.game-desc { margin: 0.5rem 0; }
.game-desc p { margin: 0.5rem 0; }

.locked-note { color: var(--success); margin: 0.5rem 0; }

.submitted-summary {
  background: #eaf4ee;
  border: 1px solid #b9d7c4;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0 0.75rem;
}
.submitted-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--success);
  font-weight: 600;
}
.submitted-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  margin-top: 0.15rem;
}
.score-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}
.score-actions > form { margin: 0; }
.score-actions > button,
.score-actions > form > button { flex: 1; }

.winloss-form {
  display: flex;
  gap: 0.6rem;
  margin: 1rem 0 0.5rem;
}
.winloss-form button {
  flex: 1;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 56px;
}
.cancel-row { margin-top: 0.6rem; }

.distances-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}
.distances-grid input {
  padding: 0.55rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.submitted-detail {
  margin-top: 0.2rem;
  font-size: 0.85rem;
}

.map-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  box-shadow: 0 4px 18px rgba(11, 61, 46, 0.12);
}

.locations {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.locations li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.locations li:last-child { border-bottom: none; }
.loc-team { font-weight: 600; }
.loc-game.done { color: var(--success); }

/* Leaderboard pts/raw toggle */
.lb-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: #fff;
}
.lb-toggle-btn {
  background: #fff;
  color: var(--ink);
  border: none;
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 0;
  border-radius: 0;
}
.lb-toggle-btn + .lb-toggle-btn { border-left: 1px solid var(--border); }
.lb-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}
.lb-wrap.show-pts .raw { display: none; }
.lb-wrap.show-raw .pts { display: none; }
.lb-wrap .raw { font-variant-numeric: tabular-nums; }

.leaderboard, .admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.leaderboard th, .leaderboard td,
.admin-table th, .admin-table td {
  padding: 0.4rem 0.3rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.leaderboard th { font-weight: 600; }
.leaderboard th.game-col {
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  white-space: normal;
  line-height: 1.15;
  vertical-align: bottom;
  color: var(--muted);
}
.leaderboard td + td { text-align: center; }
.leaderboard .total { font-weight: 700; text-align: right; }
.admin-table input { padding: 0.4rem; }
.inline-form {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form button { padding: 0.3rem 0.6rem; min-height: 0; }

.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.5rem;
}

code { background: #eee5cf; padding: 0.05rem 0.4rem; border-radius: 4px; font-size: 0.85em; }

/* Splash */
.splash {
  text-align: center;
  padding: 1rem 0;
}
.splash-img {
  width: 100%;
  max-width: 480px;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 0 auto 1.25rem;
  box-shadow: 0 4px 18px rgba(11, 61, 46, 0.12);
}
.splash-title { font-size: 2rem; margin: 0 0 0.75rem; color: var(--accent); }
.splash-note { font-size: 1.05rem; line-height: 1.5; margin: 0 auto 1rem; max-width: 28rem; }
.splash-footnote { font-size: 0.85rem; margin-top: 2rem; }

/* Danger zone */
.danger-heading { color: var(--warn); }
.danger-card { border-color: var(--warn); }
.banner-danger {
  background: #fde2d6;
  border: 1px solid #e9a081;
  color: #7a2d12;
  padding: 0.75rem;
  border-radius: 6px;
  margin: 0 0 1rem;
}
.btn-danger, .btn-danger-link {
  background: var(--warn);
  color: #fff;
  border: 1px solid var(--warn);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
}
.btn-danger:hover, .btn-danger-link:hover { background: #962d12; }

.snapshot-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Presence card */
.presence-table { font-size: 0.85rem; }
.presence-role {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  margin-right: 0.4rem;
  text-transform: uppercase;
  vertical-align: middle;
}
.role-admin { background: var(--warn); color: #fff; }
.role-team { background: var(--accent-light); color: #fff; }
.presence-label { font-weight: 500; }
.presence-ip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }

.pin-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; }
.recover-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.recover-link:hover { text-decoration: underline; }

/* Bottom nav */
body.has-nav main {
  padding-bottom: 5rem;
}
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  padding: 0.7rem 0.4rem;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-top: 3px solid transparent;
  min-height: 48px;
}
.bottom-nav a.active {
  color: var(--accent);
  border-top-color: var(--accent);
  background: #faf6ea;
}
