/* Moisty's Fantasy League — Augusta green, Masters yellow, scoreboard white.
   Mobile first: everything is laid out for a phone held in one hand, then
   widened at 760px. No external fonts or frameworks, so the PWA shell works
   offline and paints instantly. */

:root {
  --green: #006747;
  --green-dark: #004b33;
  --green-deep: #00341f;
  --green-tint: #e6f0ea;
  --yellow: #fce300;
  --yellow-soft: #fff6b3;
  --cream: #f6f4ec;
  --paper: #ffffff;
  --ink: #17251d;
  --muted: #5b6b61;
  --line: #dde3da;
  /* The Masters board: red numbers under par, green over. */
  --under: #c8102e;
  --over: #006747;
  --azalea: #d6457a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 52, 31, 0.06), 0 4px 14px rgba(0, 52, 31, 0.07);
  /* Light-only tints, tokenised so dark mode can swap them. */
  --red-tint: #fde7ea;
  --red-ink: #8b0f24;
  --yellow-ink: #4d4300;
  --gray-tint: #eceee9;
  --picked-tint: #f1f7f3;
  --hover: #fafbf8;
  --faint: #b8c2bb;
  --input-bg: #ffffff;
  --input-border: #c9d1ca;
  --selected: #fffdf0;
  --danger-ring: #f1c4cc;
  --me-ink: var(--ink);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--cream);
  padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); color: var(--green-deep); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.muted { font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--green);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 3px solid var(--yellow);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.brand-name {
  font-family: var(--serif); font-size: 1.15rem; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--yellow);
}
.brand-league { display: block; font-family: var(--sans); font-size: .75rem; color: #d7e9de; font-weight: 500; }
.topbar .spacer { flex: 1; }
.league-switch select {
  background: var(--green-dark); color: #fff; border: 1px solid #2f8466; border-radius: 8px;
  padding: 6px 8px; font-size: .85rem; max-width: 42vw;
}
.topnav { display: none; }

/* ------------------------------------------------------------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .04);
}
.tabbar a {
  height: var(--tabbar);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  position: relative;
}
.tabbar a:hover { text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--green); }
.tabbar a.active svg { stroke: var(--green); }
.tabbar a.active::before {
  content: ""; position: absolute; top: 0; left: 50%; margin-left: -14px;
  width: 28px; height: 3px; border-radius: 3px; background: var(--yellow);
}

/* --------------------------------------------------------------- layout */
main { max-width: 1040px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.cols-2, .cols-3 { grid-template-columns: 1fr; }

.card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; overflow: hidden;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 16px 0; }

/* The green scoreboard card at the top of the dashboard. */
.hero {
  background: linear-gradient(160deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  border-radius: 50%; border: 18px solid rgba(252, 227, 0, .12);
}
.hero h2 { color: #fff; margin-bottom: 2px; }
.hero .eyebrow { color: var(--yellow); }
.hero .muted, .hero small { color: #cfe3d7; }
.hero a { color: var(--yellow); }

.eyebrow {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--green); margin-bottom: 4px;
}

/* --------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 10px; text-align: center; min-width: 0;
}
.stat .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.stat .value { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; color: var(--green-deep); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { font-size: .75rem; color: var(--muted); }
a.stat { display: block; }
a.stat, a.mypick { color: inherit; transition: transform .1s; }
a.stat:hover, a.mypick:hover { text-decoration: none; }
a.stat:active, a.mypick:active { transform: scale(.98); }
a.stat .sub { color: var(--green); }

.help ul { margin: 0; padding-left: 1.2em; }
.help li { margin: 6px 0; line-height: 1.45; }

/* --------------------------------------------------------------- pick box */
.mypick { display: flex; align-items: center; gap: 12px; margin-top: 14px; background: rgba(255,255,255,.08); border-radius: 12px; padding: 12px; }
.mypick .who { flex: 1; min-width: 0; }
.mypick .name { font-weight: 700; font-size: 1.05rem; color: #fff; }
.mypick .pos { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--yellow); text-align: right; line-height: 1; }
.mypick .money { font-size: .85rem; color: #e9f3ed; text-align: right; }

.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--green-tint); flex: none; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.lg { width: 96px; height: 96px; border: 3px solid var(--yellow); }
.flag { width: 18px; height: 12px; object-fit: cover; border-radius: 2px; vertical-align: -1px; margin-right: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 0;
  background: var(--green); color: #fff; font-weight: 700; font-size: .95rem;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn.yellow { background: var(--yellow); color: var(--green-deep); }
.btn.yellow:hover { background: #f0d800; }
.btn.ghost { background: transparent; color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.btn.ghost:hover { background: var(--green-tint); }
.btn.danger { background: var(--paper); color: var(--under); box-shadow: inset 0 0 0 2px var(--danger-ring); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase; background: var(--green-tint); color: var(--green-dark);
  white-space: nowrap; vertical-align: 1px;
}
.badge.live { background: var(--under); color: #fff; }
.badge.live::before { content: "●"; margin-right: 4px; animation: pulse 1.4s infinite; }
.badge.final { background: var(--green-deep); color: var(--yellow); }
.badge.yellow { background: var(--yellow); color: var(--green-deep); }
.badge.warn { background: var(--red-tint); color: var(--under); }
.badge.gray { background: var(--gray-tint); color: var(--muted); }
.badge.major { background: var(--azalea); color: #fff; }
@keyframes pulse { 50% { opacity: .35; } }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.me td { background: var(--yellow-soft); color: var(--me-ink); }
tr.picked td { background: var(--picked-tint); }
tr.out td { color: var(--muted); }
.board th { background: var(--green); color: #fff; border-bottom: 0; }
.board th:first-child { border-top-left-radius: 8px; }
.board th:last-child { border-top-right-radius: 8px; }
.pos { font-weight: 700; font-family: var(--serif); width: 1%; white-space: nowrap; }
.under, .rounds.under { color: var(--under); font-weight: 700; }
.over, .rounds.over { color: var(--over); font-weight: 700; }
.even { color: var(--ink); font-weight: 700; }
.player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player .pname { font-weight: 600; color: var(--ink); }
.player .pmeta { font-size: .78rem; color: var(--muted); }
.rounds { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.pickers { font-size: .75rem; color: var(--green); font-weight: 700; }

/* --------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); }
.row-link { display: flex; align-items: center; gap: 12px; color: inherit; width: 100%; }
.row-link:hover { text-decoration: none; }
.chev { color: var(--faint); flex: none; }

.event { display: flex; gap: 12px; align-items: stretch; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; }
.event:hover { text-decoration: none; background: var(--hover); }
.event:last-child { border-bottom: 0; }
.event .date { flex: none; width: 54px; text-align: center; border-radius: 10px; background: var(--green-tint); padding: 6px 0; }
.event .date .m { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--green); }
.event .date .d { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; color: var(--green-deep); line-height: 1.1; }
.event.current .date { background: var(--yellow); }
.event.past .date { background: var(--gray-tint); }
.event .info { flex: 1; min-width: 0; }
.event .name { font-weight: 700; color: var(--ink); }
.event .meta { font-size: .82rem; color: var(--muted); }
.event.excluded { opacity: .55; }
.month { font-family: var(--serif); font-size: .95rem; color: var(--green); margin: 18px 0 2px; border-bottom: 2px solid var(--yellow); display: inline-block; }

/* --------------------------------------------------------------- forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(0, 103, 71, .2); border-color: var(--green); }
.field { margin-bottom: 14px; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.field .errors, .errorlist { color: var(--under); font-size: .85rem; margin: 4px 0 0; padding: 0; list-style: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--green); flex: none; }
.check .help { font-weight: 400; }
.inline-fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0 0 14px; }
legend { font-family: var(--serif); font-weight: 700; color: var(--green-deep); padding: 0 6px; }

.auth { max-width: 420px; margin: 4vh auto 0; }
.auth .logo { display: block; width: 180px; height: 180px; margin: 0 auto 14px; border-radius: 22px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; }

/* --------------------------------------------------------------- messages */
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; background: var(--green-tint); color: var(--green-deep); font-weight: 600; font-size: .92rem; }
.messages li.error { background: var(--red-tint); color: var(--red-ink); }
.messages li.warning { background: var(--yellow-soft); color: var(--yellow-ink); }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--yellow-soft); color: var(--yellow-ink); font-size: .92rem; }
.notice.alert { background: var(--red-tint); color: var(--red-ink); }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* --------------------------------------------------------------- picker */
.picker-search { position: sticky; top: 64px; z-index: 5; background: var(--cream); padding: 8px 0; }
.picker label.option {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; margin: 0 0 6px;
  background: var(--paper); box-shadow: var(--shadow); font-weight: 500; cursor: pointer;
}
.picker input[type=radio] { width: 22px; height: 22px; accent-color: var(--green); flex: none; margin: 0; }
.picker label.option:has(input:checked) { outline: 3px solid var(--yellow); background: var(--selected); }
.picker label.option.blocked { opacity: .5; cursor: not-allowed; }
.picker .grow { flex: 1; min-width: 0; }
.sticky-submit {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + var(--safe-bottom)); z-index: 25;
  padding: 10px 16px; background: linear-gradient(to top, var(--cream) 70%, transparent);
}
.sticky-submit .btn { max-width: 520px; margin: 0 auto; display: flex; }

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }

/* --------------------------------------------------------------- course */
.holes { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; font-size: .72rem; text-align: center; }
.holes div { background: var(--green-tint); padding: 4px 0; border-radius: 4px; }
.holes .h { background: var(--green); color: #fff; font-weight: 700; }
.holes .p { font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

details summary { cursor: pointer; font-weight: 700; color: var(--green); padding: 4px 0; }
details.reveal > summary { padding: 0 16px 14px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: var(--paper); color: var(--muted); font-weight: 700; font-size: .85rem; white-space: nowrap; box-shadow: var(--shadow); }
.tabs a.active { background: var(--green); color: #fff; }
.tabs a:hover { text-decoration: none; }

.pagination { display: flex; justify-content: center; gap: 8px; align-items: center; margin-top: 12px; }
.install { display: none; }
.install.show { display: flex; }
.footer { text-align: center; font-size: .75rem; color: var(--muted); margin: 26px 0 0; }

/* --------------------------------------------------------------- phones */
/* Every table must fit 360px without sideways scrolling: tighter cells, no
   headshots in long boards, and .hide-sm columns dropped. */
@media (max-width: 759px) {
  table { font-size: .85rem; }
  th { padding: 8px 6px; font-size: .64rem; letter-spacing: .04em; }
  td { padding: 9px 6px; }
  td:first-child, th:first-child { padding-left: 12px; }
  td:last-child, th:last-child { padding-right: 12px; }
  .hide-sm { display: none; }
  .board .avatar { display: none; }
  .board .player { gap: 0; }
  .rounds { white-space: normal; }
  td.num { white-space: nowrap; }
  .stat { padding: 10px 6px; }
  .stat .value { font-size: 1.2rem; }
}

/* --------------------------------------------------------------- wider */
@media (min-width: 760px) {
  body { padding-bottom: 24px; }
  .tabbar { display: none; }
  .sticky-submit { bottom: 0; }
  .topnav { display: flex; gap: 4px; margin-left: 16px; }
  .topnav a { color: #d7e9de; font-weight: 600; padding: 8px 12px; border-radius: 999px; font-size: .92rem; }
  .topnav a:hover { background: var(--green-dark); text-decoration: none; }
  .topnav a.active { background: var(--yellow); color: var(--green-deep); }
  main { padding: 24px; }
  h1 { font-size: 2rem; }
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .cols-3 { grid-template-columns: repeat(3, 1fr); }
  .stats { gap: 14px; }
  .stat .value { font-size: 1.7rem; }
  .picker-search { top: 70px; }
  .picker .options { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
}

/* --------------------------------------------------------------- dark */
/* Night at Augusta: deep green surfaces, cream text, yellow kept for accent.
   The header, hero and buttons are already green-on-white and stay as they
   are. Red/green scores are lightened to stay readable on dark. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --cream: #0c1a13;
    --paper: #13261c;
    --ink: #e9efe9;
    --muted: #9fb2a6;
    --line: #23392c;
    --green-tint: #1b3527;
    --green-deep: #d8eadf;
    --yellow-soft: #3a3410;
    --yellow-ink: #f5e98a;
    --red-tint: #3d1419;
    --red-ink: #ffb3bd;
    --gray-tint: #22332a;
    --picked-tint: #17301f;
    --hover: #183024;
    --faint: #4f665a;
    --input-bg: #0f2017;
    --input-border: #2f4a3b;
    --selected: #2b2a12;
    --danger-ring: #6b2a33;
    --under: #ff6b7d;
    --over: #5fd39a;
    --me-ink: #fff8c2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
  a, a.stat .sub { color: #7fd8a8; }
  .tabbar { box-shadow: 0 -2px 10px rgba(0, 0, 0, .4); }
  .tabbar a.active, .tabbar a.active svg { color: #7fd8a8; stroke: #7fd8a8; }
  .event .date .m { color: #7fd8a8; }
  .event.current .date { background: var(--yellow); }
  .event.current .date .m, .event.current .date .d { color: #00341f; }
  .btn.ghost { color: #7fd8a8; box-shadow: inset 0 0 0 2px #2f7a55; }
  .btn.ghost:hover { background: var(--green-tint); }
  .badge { color: #bfe3cf; }
  .badge.final { background: #00341f; }
  .badge.yellow { color: #00341f; }
  .eyebrow { color: #7fd8a8; }
  .hero .eyebrow { color: var(--yellow); }
  .month { color: #7fd8a8; }
  legend, h1, h2, h3 { color: var(--green-deep); }
  .hero h2 { color: #fff; }
  .stat .value { color: var(--green-deep); }
  .holes div { background: var(--green-tint); }
  img.avatar { background: var(--green-tint); }
}

@media (prefers-reduced-motion: reduce) {
  .badge.live::before { animation: none; }
}
