/* Road to the Title 2027 — mobile first.
   Phones are the priority: most players will use this on the course or in
   the clubhouse, one thumb, iPhone or Android. Desktop is second.
   Rules baked in: no sideways scrolling, text never below 16px, every
   button at least 48px tall, generous spacing, bottom navigation in
   easy thumb reach. */

:root {
  --green: #0b3d2e;
  --green-dark: #072a20;
  --gold: #d4af37;
  --gold-dark: #a8862a;
  --paper: #f7f5ef;
  --card: #ffffff;
  --ink: #1c1c1c;
  --muted: #5c5c5c;
  --line: #e3e0d5;
  --win: #0b6b3a;
  --danger: #a11f1f;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  /* Room for the fixed bottom nav, plus the iPhone home-indicator area. */
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; color: var(--green); }
h2 { font-size: 20px; line-height: 1.3; margin: 24px 0 8px; color: var(--green); }
p { margin: 0 0 12px; }
ul { margin: 0 0 12px; padding-left: 22px; }
li { margin-bottom: 6px; }

a { color: var(--green); }

/* ---------- header ---------- */
.site-header {
  background: var(--green);
  color: #fff;
  text-align: center;
  padding: 16px 16px 20px;
}
.logo {
  display: block;
  width: min(100%, 340px);
  height: auto;
  margin: 0 auto 8px;
  border-radius: 12px;
}
.tagline {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--gold);
}
.golflive-btn {
  display: block;
  min-height: 52px;
  line-height: 52px;
  margin: 0 auto 10px;
  max-width: 420px;
  background: var(--gold);
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  border-radius: 12px;
  padding: 0 16px;
}
.golflive-note {
  margin: 0 auto;
  max-width: 560px;
  font-size: 15px;
  color: #d9e8dd;
}

/* ---------- auth bar ---------- */
.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 16px;
  background: var(--green-dark);
  color: #fff;
  font-size: 16px;
}
.auth-bar span { overflow-wrap: anywhere; }

/* ---------- buttons & inputs (48px+ tap targets) ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  margin: 8px 0;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}
.btn:active { background: var(--green-dark); }
.btn-secondary { background: #e8e4d8; color: var(--green-dark); }
.btn-secondary:active { background: #d8d2c0; }
.btn-text { background: transparent; color: var(--muted); font-weight: 600; }
.btn-small {
  width: auto;
  min-height: 44px;
  min-width: 88px;
  margin: 0;
  padding: 8px 18px;
  font-size: 16px;
  background: var(--gold);
  color: var(--green-dark);
}
.btn[disabled] { opacity: 0.55; cursor: default; }

.input, select.input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  margin: 4px 0 12px;
  border: 2px solid #b9b4a4;
  border-radius: 12px;
  background: #fff;
  font-size: 18px;
  font-family: inherit;
  color: var(--ink);
}
.input:focus { outline: 3px solid var(--gold); outline-offset: 1px; border-color: var(--green); }
.field-label { display: block; font-size: 16px; font-weight: 700; margin-top: 12px; }
.msg { font-size: 16px; font-weight: 600; color: var(--danger); min-height: 22px; }
.msg.ok { color: var(--win); }

/* ---------- layout ---------- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}
.tab[hidden] { display: none; }
.hint { font-size: 16px; color: var(--muted); }
.updated { font-size: 15px; color: var(--muted); }
.row { display: flex; flex-direction: column; gap: 0; }
.row .input { flex: 1; }

/* ---------- league (list rows, never a scrolling table) ---------- */
.league-list { border-top: 2px solid var(--green); }
.league-head, .league-row {
  display: grid;
  grid-template-columns: 30px 1fr 92px 44px;
  gap: 8px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.league-head { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.league-row { min-height: 56px; background: var(--card); }
.league-row:nth-child(even) { background: #f2efe6; }
.league-row.me { background: #fdf3c4; }
.league-pos { font-size: 20px; font-weight: 800; color: var(--green); text-align: center; }
.league-name { font-size: 18px; font-weight: 700; line-height: 1.25; }
.league-name small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
.league-record { font-size: 16px; text-align: center; white-space: nowrap; }
.league-record small { display: block; font-size: 14px; color: var(--muted); }
.league-pts { font-size: 24px; font-weight: 800; color: var(--green); text-align: center; }
.league-pts small { display: block; font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---------- fixtures ---------- */
.round-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 0 16px;
  overflow: hidden;
}
.round-head {
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.round-head .venue { color: var(--gold); font-weight: 600; }
.round-body { padding: 12px; }
.match {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 0 0 12px;
  background: #fbfaf6;
}
.fourball-head {
  font-size: 14px;
  font-weight: 800;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 4px 8px;
}
.fourball-head:first-child { margin-top: 2px; }
.match-names {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  width: 100%;
}
.match-player { flex: 1 1 0; min-width: 0; font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: break-word; }
.match-player-b { flex: 1 1 0; min-width: 0; text-align: right; }
.match-names .vs {
  flex: 0 0 auto;
  background: var(--gold);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.match-meta { font-size: 15px; color: var(--muted); margin-bottom: 2px; }
.match-result { font-size: 17px; font-weight: 700; color: var(--win); margin: 6px 0 0; }
.match .hint { margin: 4px 0 0; }
.result-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.result-btns .btn { margin: 0; min-height: 52px; padding: 10px 4px; font-size: 16px; }
.result-btns .btn.picked { background: var(--gold); color: var(--green-dark); outline: 3px solid var(--green-dark); outline-offset: 1px; }
.ctp-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.ctp-box h3 { font-size: 17px; margin: 0 0 8px; color: var(--green); }
.ctp-winner { font-size: 17px; font-weight: 700; margin: 4px 0; }
.ctp-row { display: flex; gap: 8px; }
.ctp-row .input { flex: 1; margin: 0; }
.ctp-row .btn { width: auto; min-width: 96px; margin: 0; }
.ctp-remove { min-height: 44px; min-width: 44px; padding: 6px 12px; margin-left: 8px; border: none; border-radius: 8px; background: #f0dede; color: var(--danger); font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; }

/* ---------- players ---------- */
.player-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  min-height: 64px;
}
.player-card .pname { font-size: 18px; font-weight: 700; }
.player-card .pname small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
.player-card .precord { font-size: 16px; text-align: right; white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 800;
  color: var(--green-dark);
  background: var(--gold);
  border-radius: 6px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- organiser ---------- */
.organiser-panel {
  background: #fdf3c4;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.organiser-panel h2 { margin-top: 0; }

/* ---------- bottom nav (thumb zone) ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--green-dark);
  border-top: 2px solid var(--gold);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 20;
}
.nav-btn {
  min-height: 60px;
  border: none;
  background: transparent;
  color: #cfe0d4;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 4px;
}
.nav-btn.active { color: var(--gold); background: rgba(212, 175, 55, 0.15); }

/* ---------- login sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}

/* ---------- wider screens: desktop second ---------- */
@media (min-width: 700px) {
  body { padding-bottom: 24px; }
  .logo { width: 420px; }
  .row { flex-direction: row; gap: 12px; }
  .bottom-nav {
    position: static;
    max-width: 720px;
    margin: 24px auto 0;
    border-radius: 14px;
    border: 2px solid var(--gold);
    padding-bottom: 0;
  }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; }
}
