:root {
  --bg: #fbf6ec;
  --card: #ffffff;
  --ink: #22302a;
  --muted: #66736c;
  --line: #e8e0d0;
  --green: #23523f;
  --green-soft: #dcebe2;
  --orange: #e8792b;
  --orange-dark: #c45f17;
  --red: #b3372b;
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 14px; color: var(--green); }
h2 { font-size: 18px; margin: 0 0 10px; color: var(--green); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.btn {
  display: block; width: 100%; min-height: 52px; padding: 12px 18px; border-radius: 14px;
  font-weight: 700; text-align: center; background: var(--green-soft); color: var(--green);
}
.btn + .btn { margin-top: 10px; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.go { background: var(--orange); color: #fff; min-height: 76px; font-size: 22px; margin-bottom: 14px; box-shadow: 0 6px 16px rgba(232,121,43,.35); }
.btn.link { background: none; min-height: 44px; font-weight: 600; }
.btn.danger { background: none; color: var(--red); min-height: 44px; }
.btn:disabled { opacity: .55; }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn + .btn { margin-top: 0; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
input[type=text], input[type=number], input[type=date] {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.code-input { text-transform: uppercase; letter-spacing: .08em; }
.error { color: var(--red); font-weight: 600; font-size: 14px; min-height: 20px; margin-bottom: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--green); line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

.progress { height: 14px; background: var(--green-soft); border-radius: 8px; overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; background: var(--orange); border-radius: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; text-align: left; }
.item .grow { flex: 1; min-width: 0; }
.item .grow b, .item .grow span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .grow span { font-size: 13px; color: var(--muted); }
.item .num { font-weight: 700; color: var(--green); white-space: nowrap; }
.rank { width: 26px; text-align: center; font-weight: 700; color: var(--muted); flex: none; }
li.mine { background: var(--green-soft); margin: 0 -8px; padding: 0 8px; border-radius: 10px; border-top: 0; }

.avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--green-soft); flex: none; display: grid; place-items: center; font-size: 22px; }
.avatar.big { width: 96px; height: 96px; font-size: 44px; }

.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 2px; border-radius: 12px; }
.badge i { display: block; font-style: normal; font-size: 28px; filter: grayscale(1); opacity: .35; }
.badge.won { background: var(--green-soft); color: var(--green); font-weight: 600; }
.badge.won i { filter: none; opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 22px; background: #fff; border: 1px solid var(--line); font-weight: 600; }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }

.code-box { font: 700 26px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; background: var(--green-soft); color: var(--green); padding: 14px; border-radius: 12px; margin: 10px 0; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; justify-content: center;
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs[hidden] { display: none; }
#tabs button { flex: 1; max-width: 140px; min-height: 62px; font-size: 12px; color: var(--muted); font-weight: 600; }
#tabs button i { display: block; font-style: normal; font-size: 22px; line-height: 1.2; }
#tabs button.on { color: var(--orange-dark); }

/* The walk screen */
#track { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#map { flex: 1; min-height: 120px; background: var(--green-soft); }
.panel { background: #fff; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 800; }
.panel .inner { max-width: 560px; margin: 0 auto; }
.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-bottom: 10px; }
.big-stats b { display: block; font-size: 30px; line-height: 1.15; color: var(--green); font-variant-numeric: tabular-nums; }
.big-stats span { font-size: 12px; color: var(--muted); }
.status { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 10px; min-height: 18px; }
.status.warn { color: var(--orange-dark); font-weight: 600; }

#route-map { height: 240px; border-radius: 12px; margin-bottom: 12px; background: var(--green-soft); }

#sheet-wrap { position: fixed; inset: 0; z-index: 1000; background: rgba(20,30,25,.5); display: flex; align-items: flex-end; justify-content: center; }
#sheet-wrap[hidden] { display: none; }
#sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 1100;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; text-align: center; font-weight: 600;
}
#toast[hidden] { display: none; }
#toast.top { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }

.centre { text-align: center; }
.hero-paw { font-size: 52px; text-align: center; line-height: 1.1; }
.tabs-mini { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs-mini button { flex: 1; min-height: 44px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-weight: 600; }
.tabs-mini button.on { background: var(--green); border-color: var(--green); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .progress i { transition: width .5s ease; }
}
