:root {
  --green: #0b3d2e;
  --green-2: #12674a;
  --accent: #f5c518;
  --bg: #0e1411;
  --card: #182420;
  --card-2: #1f2f29;
  --text: #eef3f0;
  --muted: #9bb0a7;
  --line: #2a3a34;
  --good: #36c275;
  --bad: #e2574c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body { padding-bottom: calc(74px + var(--safe-bottom)); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-2) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.topbar .title { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.chip {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

main { padding: 14px 14px 0; max-width: 720px; margin: 0 auto; }
h2 { font-size: 18px; margin: 4px 2px 12px; }

/* Filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; -webkit-overflow-scrolling: touch; }
.filters button {
  flex: 0 0 auto;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.filters button.active { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }

/* Day / round groupings */
.daygroup { margin-bottom: 18px; }
.daygroup > .dayhead {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 6px 4px 8px;
}

/* Match card */
.match {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.match .meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.match .badge {
  font-weight: 700;
  color: var(--accent);
}
.match .lockflag { color: var(--muted); }

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.team { font-weight: 700; }
.team.home { text-align: right; }
.team.away { text-align: left; }
.vs { color: var(--muted); font-size: 13px; }

/* Score inputs */
.scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.scoreline input {
  width: 100%;
  max-width: 64px;
  justify-self: center;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  padding: 8px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
}
.scoreline input:disabled { opacity: .55; }
.scoreline .dash { text-align: center; color: var(--muted); font-weight: 800; }

.match .actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  background: var(--accent);
  color: #1a1a1a;
}
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }

.result-line { font-size: 13px; font-weight: 700; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.pill.p3 { background: rgba(54,194,117,.18); color: var(--good); }
.pill.p1 { background: rgba(245,197,24,.18); color: var(--accent); }
.pill.p0 { background: rgba(226,87,76,.16); color: var(--bad); }
.pill.final { background: var(--card-2); color: var(--muted); }
.saved-tick { color: var(--good); font-weight: 800; }

/* Leaderboard */
.lb { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}
.lb-row:last-child { border-bottom: none; }
.lb-row .rank { font-weight: 800; color: var(--muted); text-align: center; }
.lb-row.top .rank { color: var(--accent); }
.lb-row .name { font-weight: 800; font-size: 17px; }
.lb-row .sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.lb-row .pts { font-size: 22px; font-weight: 900; }
.lb-row .pts small { font-size: 12px; color: var(--muted); font-weight: 700; }
.lb-row.me { background: rgba(245,197,24,.07); }

.rules {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.rules ul { margin: 8px 0; padding-left: 18px; }
.rules li { margin: 3px 0; }

/* Admin */
.admin-pin { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.admin-pin input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 16px;
}
.edit-row { display: flex; gap: 8px; margin-top: 8px; }
.edit-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-size: 14px; }
.linkbtn { background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; }

/* Player picker overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(180deg, var(--green) 0%, var(--bg) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay .card { text-align: center; max-width: 360px; width: 100%; }
.overlay .logo { font-size: 56px; }
.overlay h1 { font-size: 26px; margin: 8px 0 4px; }
.who-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.who-buttons button {
  padding: 16px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #1a1a1a;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

/* Tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabbtn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  padding: 10px 0 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tabbtn span { font-size: 11px; font-weight: 700; }
.tabbtn.active { color: var(--accent); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--good); color: #07150d; }

.tznote { margin: -4px 4px 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
