:root {
  --bg: #f3f6f1;
  --card: #ffffff;
  --text: #1c2a22;
  --muted: #5d6b63;
  --line: #dde5df;
  --brand: #1f6b43;
  --brand-text: #ffffff;
  --ball: #d4e83a;
  --yes: #1f8a4c;
  --yes-soft: #e3f4e9;
  --no: #b3413b;
  --no-soft: #f9e6e4;
  --wait: #a36a00;
  --wait-soft: #fbf0d9;
  --shadow: 0 1px 3px rgba(20, 40, 30, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111814;
    --card: #1a231e;
    --text: #e6ede8;
    --muted: #9aa8a0;
    --line: #2c3831;
    --brand: #3a9a66;
    --yes: #4cc47f;
    --yes-soft: #1c3527;
    --no: #e27b74;
    --no-soft: #3a2220;
    --wait: #e0a83a;
    --wait-soft: #3a2e14;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }

header.top {
  background: var(--brand);
  color: var(--brand-text);
  padding: 14px 16px;
}
header.top .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
header.top a { color: inherit; text-decoration: none; font-weight: 700; font-size: 19px; }
.ball {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ball);
  box-shadow: inset 3px 0 0 -1px #fff8, inset -3px 0 0 -1px #fff8;
  flex: none;
}
header.top .spacer { flex: 1; }
header.top .small { font-size: 14px; font-weight: 500; opacity: 0.9; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
h1 { font-size: 24px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.event-when { font-size: 18px; margin: 6px 0 2px; }
.event-where { color: var(--muted); margin: 0 0 14px; }
.note { background: var(--wait-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.owner-notice {
  background: var(--wait-soft); color: var(--text);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 15px; overflow-wrap: anywhere;
}
.cancel-banner { background: var(--no-soft); color: var(--no); border-radius: 10px; padding: 12px; font-weight: 600; margin: 10px 0; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.choices button { padding: 10px 6px; white-space: nowrap; }
button, .button {
  font: inherit; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: 0.55; cursor: default; }
.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.choice-yes.on { background: var(--yes); border-color: var(--yes); color: #fff; }
.choice-yes.on.waiting { background: var(--wait); border-color: var(--wait); color: #fff; }
.choice-maybe.on { background: var(--wait); border-color: var(--wait); color: #fff; }
.choice-no.on { background: var(--no); border-color: var(--no); color: #fff; }
.link-btn { background: none; border: none; color: var(--brand); padding: 6px 0; min-height: 0; font-weight: 600; }
.danger { color: var(--no); }
.full { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.status { border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; font-weight: 600; }
.status.going { background: var(--yes-soft); color: var(--yes); }
.status.waitlist { background: var(--wait-soft); color: var(--wait); }
.status.maybe { background: var(--wait-soft); color: var(--wait); }
.status.no { background: var(--no-soft); color: var(--no); }

.count-line { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 15px; margin: 0 0 4px; }
.count-line b { color: var(--text); }

ul.people { list-style: none; padding: 0; margin: 0; }
ul.people li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
ul.people li:last-child { border-bottom: none; }
.num { width: 24px; color: var(--muted); font-size: 14px; text-align: right; flex: none; }
.pname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge {
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.Beginner { background: #e8f1fb; color: #2a5d8f; border-color: #cfe0f3; }
.badge.Intermediate { background: var(--wait-soft); color: var(--wait); border-color: transparent; }
.badge.Advanced { background: var(--no-soft); color: var(--no); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.Beginner { background: #1a2a3a; color: #8bb8e6; border-color: transparent; }
}
.empty { color: var(--muted); font-style: italic; padding: 6px 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 15px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=time], input[type=date], select, textarea {
  font: inherit; width: 100%;
  padding: 11px 12px; min-height: 48px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
textarea { min-height: 80px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 14px 0; }
.check input { width: 22px; height: 22px; flex: none; }
.form-actions { margin-top: 18px; }

.error { background: var(--no-soft); color: var(--no); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.ok { background: var(--yes-soft); color: var(--yes); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.hidden { display: none !important; }

details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; list-style-position: inside; }

.copybox { display: flex; gap: 8px; margin-top: 8px; }
.copybox input { flex: 1; min-width: 0; font-size: 14px; }

/* organizer page */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; }
.tabs button { flex: none; min-height: 40px; padding: 8px 14px; border-radius: 999px; font-size: 15px; }
.tabs button.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.member { border-bottom: 1px solid var(--line); padding: 12px 0; }
.member:last-child { border-bottom: none; }
.member .top-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.member .details { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; margin-top: 2px; }
.member .row { margin-top: 8px; }
.member .row button { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.week { border-bottom: 1px solid var(--line); padding: 12px 0; }
.week:last-child { border-bottom: none; }
.week .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tag { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.tag.cancelled { background: var(--no-soft); color: var(--no); }
.tag.changed { background: var(--wait-soft); color: var(--wait); }
select.mini { min-height: 38px; padding: 6px 8px; width: auto; font-size: 14px; }

/* top-bar member menu */
header.top .inner { flex-wrap: wrap; }
nav#nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav#nav a {
  font-size: 15px; font-weight: 600; padding: 6px 10px; border-radius: 999px;
  color: inherit; opacity: 0.85;
}
nav#nav a.on { background: rgba(255,255,255,0.18); opacity: 1; }
@media (max-width: 480px) {
  nav#nav { width: 100%; order: 3; margin-top: 8px; }
}

/* game cards */
.game-title { font-size: 14px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 2px; }
.game h2 { margin-bottom: 2px; }
.game .meta { color: var(--muted); margin: 0 0 12px; }
.game details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.section-label { color: var(--muted); font-size: 14px; font-weight: 600; margin: 4px 0 10px; }

/* board */
.post { border-bottom: 1px solid var(--line); padding: 12px 0; }
.post:last-child { border-bottom: none; }
.post .who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.post .when { color: var(--muted); font-size: 13px; }
.post .text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.post .link-btn { font-size: 13px; }

/* email-writing box */
dialog.composer {
  border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--card); color: var(--text);
}
dialog.composer::backdrop { background: rgba(0, 0, 0, 0.45); }

/* board topics */
a.topic-row {
  display: block; color: inherit; text-decoration: none;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
a.topic-row:last-child { border-bottom: none; }
a.topic-row:hover .topic-title { color: var(--brand); }
.topic-title { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.topic-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.post.first { padding-top: 4px; }
.post.first .text { font-size: 17px; }

/* alert switch */
.alert-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 15px; margin-top: 10px; }
.follow-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 6px 0 12px; }
button.switch {
  position: relative; width: 50px; min-height: 30px; height: 30px; padding: 0;
  border-radius: 999px; background: var(--line); border: none; flex: none;
}
button.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s;
}
button.switch.on { background: var(--yes); }
button.switch.on .knob { left: 23px; }

/* big greeting on the home page */
h1.greeting { font-size: 32px; margin: 4px 0 2px; }

.meet-alert { margin-top: 12px; flex-wrap: nowrap; }
.meet-alert .small { color: var(--muted); }

.bell { display: inline-flex; vertical-align: -4px; flex: none; }
.topic-title .bell svg { width: 18px; height: 18px; }

/* ⭐ home-screen help */
.star-btn {
  background: none; border: none; min-height: 40px; padding: 4px 6px;
  font-size: 24px; line-height: 1; cursor: pointer; margin-left: 4px;
}
header.top .inner { position: relative; }
@media (max-width: 480px) {
  .top-icons { position: absolute; top: 0; right: 0; }
  header.top .inner { padding-right: 88px; }
}
.top-icons { display: inline-flex; align-items: center; gap: 2px; }
.share-btn {
  background: none; border: none; min-height: 40px; padding: 4px 6px; cursor: pointer;
  display: inline-flex; align-items: center;
}
ol.steps { padding-left: 22px; margin: 4px 0 8px; }
ol.steps li { margin: 6px 0; }
.howto-pic { margin: 8px 0 4px; max-width: 320px; }
.howto-pic svg { width: 100%; height: auto; display: block; }

.game details.comments { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.game details.comments textarea { min-height: 70px; }

/* Organizer: sign-ups waiting for approval, blocked people */
.count-dot {
  display: inline-block; margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: #d62d20; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}
.pending-card { border: 2px solid var(--wait); }
.warn-line { margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--no-soft); color: var(--no); font-size: 14px; }

/* "Might be late" */
.late-line { margin-top: 8px; gap: 10px; align-items: center; }
.late-line label.check { margin: 0; }
.late-line select { width: auto; min-height: 38px; padding: 4px 10px; }
.late-tag { font-size: 12px; font-weight: 600; color: var(--wait); white-space: nowrap; }
.game-desc { margin: 8px 0 0; white-space: pre-line; overflow-wrap: anywhere; }

/* Join page: "Email the organizer" for the group code */
.code-request { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.code-request p.small { margin: 0 0 10px; }
.request-btn { width: 100%; background: var(--line); color: var(--muted); border-color: var(--line); }
.request-btn:disabled { opacity: 1; cursor: not-allowed; }
.request-btn.ready { background: var(--yes); border-color: var(--yes); color: #fff; cursor: pointer; }
.request-btn.ready:disabled { opacity: .7; }

/* Organizer: flyer preview */
.flyer-preview-box { margin-top: 6px; }
.flyer-preview { width: 100%; aspect-ratio: 8.5 / 11; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.flyer-preview.landscape { aspect-ratio: 11 / 8.5; }
.layout-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.layout-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; cursor: pointer; font-weight: 400; }
.layout-option:has(input:checked) { border-color: var(--brand); background: var(--yes-soft); }
.layout-option input { margin-top: 3px; }
.layout-option span { display: flex; flex-direction: column; }
.layout-option small { color: var(--muted); font-size: 13px; }
.flyer-tips { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.flyer-tips summary { font-weight: 700; cursor: pointer; }
.flyer-tips h3 { margin: 14px 0 6px; font-size: 16px; }
.flyer-tips ol, .flyer-tips ul { margin: 0; padding-left: 22px; }
.flyer-tips li { margin: 6px 0; }

/* ---------- Ladder ---------- */
ol.ladder { list-style: none; margin: 8px 0 0; padding: 0; }
ol.ladder li { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
ol.ladder li:last-child { border-bottom: none; }
ol.ladder li.me { background: var(--yes-soft); border-radius: 10px; }
ol.ladder .rank { width: 30px; flex: none; text-align: center; font-weight: 800; font-size: 18px; color: var(--brand); }
.you-tag { margin-left: 6px; font-size: 12px; font-weight: 700; color: #fff; background: var(--brand); border-radius: 999px; padding: 1px 7px; }
.busy-tag { font-size: 15px; }
.challenge-btn { min-height: 36px; padding: 4px 12px; font-size: 14px; background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.challenge-card.alert { border: 2px solid var(--wait); }
.decline-btn { color: var(--no); }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 360px; overflow-y: auto; }
.bubble { max-width: 85%; align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.bubble.mine { align-self: flex-end; background: var(--yes-soft); border-color: transparent; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .when { font-size: 12px; color: var(--muted); margin-top: 2px; }
.won-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.score-form { margin-top: 8px; }
ul.results { list-style: none; margin: 0; padding: 0; }
ul.results li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.results li:last-child { border-bottom: none; }
ul.results .when { display: block; font-size: 13px; color: var(--muted); }
.mini-btn { min-height: 34px; min-width: 34px; padding: 2px 8px; font-size: 16px; }

/* Multiple ladders */
.ladder-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0 12px; padding-bottom: 2px; }
.ladder-tabs button { flex: none; min-height: 42px; padding: 8px 14px; border-radius: 999px; font-size: 15px; }
.ladder-tabs button.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.tab-rank { margin-left: 6px; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.25); border-radius: 999px; padding: 1px 7px; }
.ladder-tabs button:not(.on) .tab-rank { background: var(--yes-soft); color: var(--brand); }
.kind-tag { margin-left: 8px; vertical-align: middle; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: var(--wait-soft); color: var(--wait); }
.ladder-tag { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--wait); }
.join-ladder { background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.join-ladder p { margin: 0 0 10px; }
.join-ladder select { flex: 1; min-width: 160px; }

/* Link back to playlocalcourts.com at the bottom of every page */
.plc-footer { max-width: 680px; margin: 10px auto 28px; padding: 0 16px; display: flex; justify-content: center; }
.plc-home { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); text-decoration: none; }
.plc-home:hover { border-color: var(--brand); }
.plc-home img { width: 46px; height: 35px; flex: none; }
.plc-home span { display: flex; flex-direction: column; line-height: 1.2; }
.plc-home b { color: var(--brand); font-size: 15px; }
.plc-home small { color: var(--muted); font-size: 12.5px; }
