/* You're the Star — mobile-first.
   Designed for phones (99% of traffic) and progressively enhanced upward.
   Brand: deep teal #0E3A34, gold #F2B134 (from the star logo). */

:root {
  --teal: #0E3A34;
  --teal-mid: #15514A;
  --gold: #F2B134;
  --gold-soft: #FFDA8C;
  --bg: #F7F8F7;
  --card: #FFFFFF;
  --line: #E2E6E4;
  --text: #16211F;
  --muted: #667874;
  --ok: #1B7F5A;
  --bad: #C0392B;
  --radius: 12px;
  --tap: 44px; /* minimum comfortable tap target */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;              /* 16px+ stops iOS zooming on input focus */
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- header ---------- */
.site-header {
  background: var(--teal);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.site-header a { color: #fff; text-decoration: none; }
.site-header .brand { font-weight: 700; font-size: 17px; }
.site-header .brand .star { color: var(--gold); }
.site-header .spacer { flex: 1; }
.site-header .hdr-link { font-size: 14px; opacity: .9; }

.wrap { padding: 16px; max-width: 720px; margin: 0 auto; }

h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card.tight { padding: 10px 12px; }

/* ---------- messages ---------- */
.msg { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 15px; }
.msg.err  { background: #FDECEA; color: #8E2A20; border: 1px solid #F5C6C0; }
.msg.ok   { background: #E7F5EF; color: #146349; border: 1px solid #BFE6D6; }
.msg.info { background: #EAF1F5; color: #1F4A5C; border: 1px solid #C6DCE6; }

/* ---------- forms ---------- */
label { display: block; margin-bottom: 10px; font-size: 15px; }
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px;              /* keep at 16px: smaller triggers iOS zoom */
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input[type=number].sm { width: 84px; min-width: 84px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
button.secondary, .btn.secondary { background: #fff; color: var(--teal); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button:disabled { opacity: .45; }
button.full { width: 100%; }

/* checkbox/radio rows get a proper tap target */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 0;
}
.check-row input { width: 22px; height: 22px; margin-top: 2px; flex: none; }

/* ---------- player / row cards (replaces wide tables on mobile) ---------- */
.row-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.row-card .who { flex: 1; min-width: 0; }
.row-card .name { font-weight: 600; }
.row-card .meta { font-size: 13px; color: var(--muted); }
.row-card .pts { font-weight: 700; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
}
.pill.boss { background: var(--gold-soft); color: #6b4a00; }
.pill.cap  { background: var(--teal); color: #fff; }
.pill.bench{ background: #E9EDEB; color: var(--muted); }

/* segmented picker: Start / Bench / Out */
.seg { display: flex; gap: 4px; flex: none; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0;
  min-width: 46px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.seg input:checked + label { background: var(--teal); border-color: var(--teal); color: #fff; }
.seg input:checked + label.bench { background: var(--muted); border-color: var(--muted); }
.seg input:checked + label.cap   { background: var(--gold); border-color: var(--gold); color: #3a2a00; }

/* ---------- sticky action bar ---------- */
.sticky-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  margin: 16px -16px 0;
  z-index: 40;
}
.counters { display: flex; gap: 12px; font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.counters span { color: var(--muted); }
.counters b { font-variant-numeric: tabular-nums; }
.counters .full-ok b { color: var(--ok); }
.counters .over b { color: var(--bad); }

/* ---------- search / filter ---------- */
.filter { position: sticky; top: 56px; background: var(--bg); padding: 8px 0; z-index: 30; }

/* ---------- tables: scroll rather than squash ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.data th, table.data td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #F0F3F2; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.data tr:last-child td { border-bottom: 0; }

/* ---------- leaderboard ---------- */
.lb-rank { width: 30px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-me { background: #FFF8E9; border-color: var(--gold); }

nav.links a { display: block; padding: 14px 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
nav.links a:after { content: "›"; float: right; color: var(--muted); }

footer.site-footer { padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 13px; }
footer.site-footer a { color: var(--muted); }

/* ---------- desktop ---------- */
@media (min-width: 768px) {
  .wrap { padding: 24px; }
  h1 { font-size: 28px; }
  .sticky-bar { position: static; margin: 16px 0 0; border-radius: var(--radius); border: 1px solid var(--line); }
  table.data th, table.data td { white-space: normal; }
}

/* ---------- brand ---------- */
.site-header .brand { display: flex; align-items: center; gap: 8px; }
.site-header .brand img { display: block; flex: none; }

.hero {
  text-align: center;
  padding: 8px 0 20px;
}
.hero img {
  width: 100%;
  max-width: 260px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
}
.hero .tagline {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 4px;
}

/* ---------- homepage ---------- */
.step {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.chev { color: var(--muted); font-size: 22px; line-height: 1; }
.hero .tagline { font-size: 16px; color: var(--text); font-weight: 500; }
code { background: #EEF1F0; padding: 2px 5px; border-radius: 5px; font-size: 14px; }
.pill.left { background: #FDECEA; color: #8E2A20; }

/* ---------- validation checklist ----------
   A disabled Save button that doesn't say WHY is a locked door with no
   sign on it. This shows exactly what's outstanding, live. */
.todo { display: none; margin-bottom: 8px; }
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13.5px;
  line-height: 1.4;
  color: #8E2A20;
  background: #FDECEA;
  border: 1px solid #F5C6C0;
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 5px;
}
.todo-item:before { content: "!"; font-weight: 700; flex: none; }
.todo-item b { font-weight: 700; }
.todo-ok {
  font-size: 13.5px;
  font-weight: 600;
  color: #146349;
  background: #E7F5EF;
  border: 1px solid #BFE6D6;
  border-radius: 9px;
  padding: 8px 10px;
}
.todo-ok:before { content: "\2713  "; font-weight: 700; }

/* ---------- leaderboards ----------
   Cards, not tables. A 4-column table with nowrap forces horizontal scrolling
   on a phone, which is the one thing guaranteed to make people give up. */
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
}
.lb-pos {
  flex: none;
  width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lb-mid { flex: 1; min-width: 0; }
.lb-team {
  font-weight: 600;
  font-size: 15px;
  /* Long team names truncate rather than pushing the points off-screen */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-sub {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-pts {
  flex: none;
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
}

/* Top 3 get the gold treatment */
.lb-row.top3 { border-color: var(--gold); background: #FFFDF6; }
.lb-row.top3 .lb-pos { color: var(--gold); }

/* ---------- scoring rules ---------- */
.rule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 6px;
}
.rule-info { flex: 1; min-width: 0; }
.rule-name { font-weight: 600; font-size: 15px; }
.rule-note { font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.rule-pts {
  flex: none;
  font-weight: 700;
  font-size: 19px;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.rule-pts.neg { color: var(--bad); }
.rule-ea { display: block; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; }

/* ---------- score entry (used on a phone, in a sports hall) ----------
   A 9-column x 80-player table is unusable on mobile. One card per player,
   with the scoring options laid out in a grid that wraps. */
.pcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.pcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.pcard-name { font-weight: 600; font-size: 15px; }
.pcard-abs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--bad);
  flex: none;
}
.pcard-abs input { width: 22px; height: 22px; margin: 0; }

.pcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}
.pcell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  min-height: var(--tap);
}
.pcell-label {
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
  font-weight: 600;
}
.pcell-label b { display: block; color: var(--ok); font-size: 11px; }
.pcell-label b.neg { color: var(--bad); }
.pcell-box { width: 24px; height: 24px; flex: none; margin: 0; }
.pcell-num { width: 52px; min-height: 34px; padding: 4px; text-align: center; flex: none; }

/* Absent = greyed out and disabled */
.pcard.is-absent { opacity: .45; }
.pcard.is-absent .pcard-abs { opacity: 1; }

/* ---------- remaining admin tables ----------
   These are lower-traffic admin screens (seasons, terms, ads, league admins).
   Rather than rewrite each as cards, let them WRAP instead of forcing a
   horizontal scroll — the nowrap was the actual culprit. Smaller type and
   tighter padding so they fit a phone. */
@media (max-width: 600px) {
  table.data { font-size: 12.5px; }
  table.data th,
  table.data td {
    white-space: normal;      /* THIS is what stops the sideways scroll */
    padding: 8px 6px;
    word-break: break-word;
  }
  table.data th { font-size: 10px; }
  /* Controls inside admin tables shouldn't force the row wide */
  table.data input[type=text],
  table.data input[type=number],
  table.data input[type=date],
  table.data select { max-width: 100%; font-size: 14px; padding: 6px; min-height: 36px; }
  table.data button { padding: 8px 10px; font-size: 13px; min-height: 36px; }
  .table-scroll { margin: 0; padding: 0; }
}

/* ---------- email/cron status ---------- */
.state-ok    { color: var(--ok); font-weight: 600; }
.state-bad   { color: var(--bad); font-weight: 600; }
.state-warn  { color: #8a6100; font-weight: 600; }
.state-muted { color: var(--muted); }
.lb-row.problem { border-color: var(--bad); background: #FFF7F6; }

/* ---------- smtp debug log ---------- */
.smtp-log {
  background: #101614;
  color: #C9E4DA;
  padding: 12px;
  border-radius: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

/* ---------- house ads (your own sites) ----------
   Deliberately understated: they're a friendly "also from us", not a banner. */
.house-ads {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.house-ads-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.house-ad {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 7px;
  text-decoration: none;
  color: var(--text);
}
.house-ad-body { flex: 1; min-width: 0; }
.house-ad-title { display: block; font-weight: 700; font-size: 15px; color: var(--teal); }
.house-ad-tag { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 1px; }
