:root {
  --green-900: #2b331a;
  --green-700: #3d4526;
  --green-600: #4e5b31;
  --green-400: #6f7d4a;
  --cream: #f5f2e6;
  --cream-dark: #e7e2cf;
  --ink: #23271a;
  --muted: #6b6f5d;
  --line: #d9d4c2;
  --white: #fffef8;
  --danger: #a3402d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 51, 26, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--green-700);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 16px;
  margin-right: auto;
}
.logo-chip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.logo-chip img { width: 32px; height: 32px; display: block; }

.hero-logo {
  display: block;
  width: 132px;
  height: 132px;
  margin: 8px auto 6px;
}
.hero-logo.sm { width: 104px; height: 104px; }
.topbar a { color: var(--cream); text-decoration: none; opacity: 0.9; font-size: 14px; text-align: center; }
.topbar a:hover { opacity: 1; }
.topbar a.active { text-decoration: underline; text-underline-offset: 4px; opacity: 1; }

.wrap { max-width: 640px; margin: 0 auto; padding: 18px 16px 64px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--green-700);
  background: var(--green-600);
  color: var(--cream);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--green-700); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: transparent; color: var(--green-700); }
.btn.secondary:hover { background: var(--cream-dark); }
.btn.block { width: 100%; }
.btn.big { padding: 15px 22px; font-size: 17px; }
.btn.dark { background: #111; border-color: #111; color: #fff; }
.btn.dark:hover { background: #000; }

/* Sign-in panel */
.signin { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.signin-sub { border-top: 1px solid var(--line); padding-top: 12px; }
.signin-sub .field:first-child { margin-top: 0; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

/* Leaderboard */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
}
.row:hover { border-color: var(--green-400); }
.row.mine { border-color: var(--green-600); background: #fbfaf2; }
.tagnum {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--green-600);
  color: var(--green-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}
.tagnum.top { background: var(--green-600); color: var(--cream); }
.holder { flex: 1 1 auto; min-width: 0; }
.holder .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.holder .name.empty { color: var(--muted); font-weight: 500; font-style: italic; }
.held { flex: 0 0 auto; color: var(--muted); font-size: 13px; text-align: right; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-400); color: var(--cream);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex: 0 0 auto;
}

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat .n { font-size: 24px; font-weight: 700; color: var(--green-700); }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

.notice { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; margin: 12px 0; }
.notice.ok { background: #eef3e0; color: var(--green-700); border: 1px solid #cddba9; }
.notice.err { background: #f6e7e2; color: var(--danger); border: 1px solid #e3c3ba; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: none; }
.timeline .tnum { font-weight: 700; color: var(--green-700); flex: 0 0 auto; width: 34px; }
.timeline .when { color: var(--muted); margin-left: auto; flex: 0 0 auto; font-size: 13px; }

.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
input, select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--white); color: var(--ink);
}
label.field { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

/* Hide the reCAPTCHA v3 badge (allowed when the disclosure text below is shown). */
.grecaptcha-badge { visibility: hidden !important; }
.recaptcha-terms {
  font-size: 11px; line-height: 1.5; color: var(--muted); margin: 12px 0 0; text-align: center;
}
.recaptcha-terms a { color: var(--muted); text-decoration: underline; }

/* Head-to-head rivalries list */
.rivals { list-style: none; margin: 0; padding: 0; }
.rivals .rival {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.rivals .rival:last-child { border-bottom: 0; }
.rival-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rival-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.rival-rec {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px;
  padding: 2px 9px; border-radius: 999px; background: var(--cream-dark); color: var(--green-700);
  min-width: 52px; text-align: center;
}
.rival-rec.up { background: #dfe7cf; color: #3f5220; }
.rival-rec.down { background: #f0dcd6; color: var(--danger); }

/* Avatars with a photo */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 92px; height: 92px; font-size: 30px; }

/* Small button variant (profile photo actions) */
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.small.ghost { background: transparent; color: var(--green-700); }
.btn.small.ghost:hover { background: var(--cream-dark); }

/* Profile editor */
.profile-edit { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pf-photo { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; }
.pf-photo-actions { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.pf-fields { flex: 1; min-width: 220px; }
.pf-fields input { width: 100%; }
.pf-msg { font-size: 13px; }
.pf-msg.err { color: var(--danger); }
@media (max-width: 480px) { .profile-edit { justify-content: center; } .pf-fields { min-width: 100%; } }

/* Ace report form (me page) */
.ar-proof { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.ar-thumb img { height: 60px; width: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.ace-subs { list-style: none; margin: 0; padding: 0; }
.ace-subs .ace-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ace-subs .ace-sub:last-child { border-bottom: none; }
.ace-status { font-family: -apple-system, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.ace-status.ok { background: #dfe7cf; color: #3f5220; }
.ace-status.pend { background: #f3ead2; color: #8a6d1c; }

/* Admin pending aces */
.pending-ace { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ace-proof-thumb { height: 56px; width: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.pa-info { flex: 1; min-width: 160px; font-size: 14px; }
.pa-actions { display: flex; gap: 8px; }

/* Bag-tags "how it works" explainer */
.howto { margin-top: 20px; text-align: left; }
.howto h2 { margin-bottom: 12px; }
.howto-steps { list-style: none; margin: 0; padding: 0; }
.howto-steps li { display: flex; gap: 14px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.howto-steps li:last-child { border-bottom: none; }
.hs-num { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--green-600); color: var(--cream); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.howto-steps b { display: block; font-size: 15px; color: var(--green-800); margin-bottom: 2px; }
.howto-steps li > div { font-size: 14px; color: var(--muted); }

/* ---- Tag page (/t/<number>) ---- */
.tagpage { max-width: 560px; margin: 0 auto; }
.tp-head { text-align: center; margin-bottom: 18px; }
.tagnum.big { width: 76px; height: 76px; font-size: 34px; margin: 0 auto 10px; }
.tp-head h1 { margin: 0; font-size: 26px; }
.tp-status { display: inline-block; vertical-align: middle; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 3px 10px; border-radius: 999px; margin-left: 6px; }
.tp-status.retired { background: var(--cream-dark); color: var(--muted); }
.tp-status.lost { background: #f2e2df; color: var(--danger); }
.tp-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 10px; }
.tp-holder { text-align: left; }
.tp-holder-now { display: flex; align-items: center; gap: 14px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.tp-holder-name { font-size: 20px; font-weight: 600; color: var(--green-700); }
.tp-holder-since { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tp-unclaimed { color: var(--muted); font-style: italic; margin: 0; }
.tp-claim { margin-top: 16px; }
.tp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.tp-stat { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px; text-align: center; }
.tp-stat-n { font-size: 22px; font-weight: 700; color: var(--green-700); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.tp-stat-l { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.tp-timeline { margin: 20px 0; }
.tp-entry { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tp-entry:last-child { border-bottom: none; }
.tp-entry-body { flex: 1; min-width: 0; }
.tp-entry-action { color: var(--ink); font-size: 15px; }
.tp-entry-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tp-foot { display: flex; gap: 10px; margin-top: 20px; }
.tp-foot .btn { flex: 1; }
@media (max-width: 420px) { .tp-stat-n { font-size: 17px; } }

/* Bag tag product photo */
.bagtag-photo { display: block; width: 100%; max-width: 400px; height: auto; margin: 0 auto 22px; border-radius: 14px; }

/* Bag tag artwork with the live tag number drawn over it. The figure is sized
   to the image and the SVG is stretched over the same box; because the SVG's
   viewBox matches the image's intrinsic 880x804, the number stays locked to the
   spot the printed numeral occupies at every width. */
.bagtag-figure { position: relative; display: block; width: 100%; max-width: 400px; margin: 0 auto 22px; }
.bagtag-figure .bagtag-photo { max-width: none; margin: 0; }
.bagtag-num { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Times has lining figures — Georgia's old-style numerals would drop the 4
   below the baseline and sit the 2 at x-height, which looks wrong on a tag. */
.bagtag-num text {
  font-family: "Times New Roman", Times, serif;
  font-variant-numeric: lining-nums;
  font-size: 128px;
  fill: #4f5c28;
}

/* Simple footer for app-shell pages */
.app-foot { text-align: center; margin-top: 40px; padding: 26px 0; border-top: 1px solid var(--line); }
.app-foot a { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; color: var(--green-700); text-decoration: none; }
.app-foot a:hover { color: var(--green-900); }

/* ———— League dues / pot (admin) + join buttons (leaderboard) ———— */
.pot-note { background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 16px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink); }
.pot-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 16px; }
.pot-fig { background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 10px; text-align: center; }
.pot-fig b { display: block; font-size: 20px; color: var(--green-800, var(--ink)); line-height: 1.2; }
.pot-fig span { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.join-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.join-btn { flex: 1 1 auto; text-align: center; text-decoration: none; }

/* ———— Collapsible League rules (native <details> accordion) ———— */
.rules-acc > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 600; color: var(--ink); margin: 0;
}
.rules-acc > summary::-webkit-details-marker { display: none; }
.rules-acc > summary::after {
  content: "⌄"; margin-left: auto; font-size: 18px; line-height: 1; color: var(--muted);
  transform: translateY(-3px); transition: transform .2s ease;
}
.rules-acc[open] > summary::after { transform: translateY(2px) rotate(180deg); }
.rules-acc > summary:hover { color: var(--green-700); }
.rules-acc[open] > summary { margin-bottom: 12px; }

/* Gentle prompt to add a profile photo — hidden once one is set. */
.pf-nudge {
  flex: 1 0 100%; margin: 4px 0 0; padding: 11px 13px; border-radius: var(--radius);
  background: var(--cream); border: 1px dashed var(--line);
  font-size: 13.5px; line-height: 1.5; color: var(--muted);
}
.pf-nudge b { color: var(--ink); }
.pf-nudge[hidden] { display: none; }

/* Opt-in "text me a challenge" — checkbox on the profile, link on the tag page */
.pf-check { display: flex; align-items: flex-start; gap: 9px; margin-top: 14px; font-size: 14px; cursor: pointer; }
.pf-check input { margin: 2px 0 0; flex: none; width: 16px; height: 16px; accent-color: var(--green-700); }
.pf-hint { font-size: 12.5px; line-height: 1.45; margin: 6px 0 0; }
.tp-challenge {
  display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 600;
  color: var(--green-700); text-decoration: none; border-bottom: 1px solid currentColor;
}
.tp-challenge:hover { color: var(--green-900); }
