:root {
  --green: #1e6b4f;
  --green2: #2e7d64;
  --green-soft: #e9f4ef;
  --ink: #1c2620;
  --muted: #5d6b64;
  --line: #d6e3dc;
  --bg: #f6faf8;
  --card: #ffffff;
  --amber: #b7791f;
  --red: #b23b3b;
  --shadow: 0 1px 3px rgba(20, 50, 40, .1), 0 4px 16px rgba(20, 50, 40, .06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--green); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--green); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; }
.topbar .sp { flex: 1; }
.topbar .who { font-size: 13px; opacity: .9; }
.topbar button.link { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
h1, h2, h3 { line-height: 1.2; }
h2 { color: var(--green); margin: 4px 0 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
input, select {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 14px 18px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.err { color: var(--red); font-size: 14px; margin: 8px 0; }
.pill { display:inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.live { background: #fdecea; color: var(--red); }
.pill.draft { background: #fff5e6; color: var(--amber); }
.pill.locked { background: var(--green-soft); color: var(--green); }

/* Sticky running total */
.scorebar {
  position: sticky; top: 52px; z-index: 15;
  background: var(--green2); color: #fff; border-radius: 12px;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.scorebar .total { font-size: 30px; font-weight: 800; margin-left: auto; }
.scorebar .lbl { font-size: 13px; opacity: .9; }

/* Mission card */
.mission { padding: 14px 16px; }
.mission .mhead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.mission .mnum { font-weight: 800; color: var(--green); font-size: 13px;
  background: var(--green-soft); border-radius: 8px; padding: 2px 8px; }
.mission .mname { font-weight: 700; }
.mission .mpts { margin-left: auto; font-weight: 700; color: var(--green2); }
.mission .blurb { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.opt { margin: 8px 0; }
.opt .optlabel { font-size: 15px; }

/* Toggle (bool) */
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: pointer; text-align: left; font-size: 15px;
}
.toggle .box {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--line);
  flex: none; display: grid; place-items: center; color: #fff; font-weight: 800;
}
.toggle.on { border-color: var(--green); background: var(--green-soft); }
.toggle.on .box { background: var(--green); border-color: var(--green); }
.toggle.penalty.on { border-color: var(--red); background: #fdecea; }
.toggle.penalty.on .box { background: var(--red); border-color: var(--red); }

/* Counter */
.counter { display: flex; align-items: center; gap: 12px; }
.counter button {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--green);
  background: #fff; color: var(--green); font-size: 24px; font-weight: 700; cursor: pointer;
}
.counter .val { font-size: 22px; font-weight: 800; min-width: 40px; text-align: center; }

/* Choice */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  flex: 1; min-width: 90px; padding: 12px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: pointer; text-align: center; font-size: 14px;
}
.choice.on { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 700; }

/* Standings table */
table.stand { width: 100%; border-collapse: collapse; }
table.stand th, table.stand td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.stand th { color: var(--green); font-size: 13px; }
table.stand td.rank { font-weight: 800; color: var(--green2); width: 44px; }
table.stand td.score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.center { text-align: center; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 50; font-size: 14px;
}
.offline-banner { background: var(--amber); color: #fff; text-align: center; padding: 6px; font-size: 13px; }

/* Admin */
.wrap.wide { max-width: 960px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }
.eventrow { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.eventrow:hover { background: var(--green-soft); }
.eventrow .nm { font-weight: 700; }
.eventrow .meta { color: var(--muted); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 44px; height: 26px; border-radius: 999px; background: #cdd8d2; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,40,32,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.chip { display: inline-block; background: var(--green-soft); color: var(--green); border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
textarea { width: 100%; min-height: 120px; padding: 12px; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; font-family: ui-monospace, Consolas, monospace; }
.tabbar { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.tab.on { background: var(--green); color: #fff; border-color: var(--green); }
