:root {
  --green: #0E4B3A;
  --green-deep: #072E23;
  --green-soft: #DCE9DF;
  --gold: #C89B2A;
  --gold-soft: #F4E7C3;
  --ink: #14231C;
  --muted: #5B6B62;
  --paper: #F2F5F1;
  --card: #FFFFFF;
  --line: #CFDAD2;
  --danger: #A63D2F;
  --radius: 14px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper);
  line-height: 1.5; font-size: 16px; min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--green); }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.75rem + env(safe-area-inset-top)) 1.1rem .75rem; background: var(--green); color: #fff;
}
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: -.01em; }
.brand svg { color: var(--gold); }
.topbadge { font-weight: 700; font-size: .9rem; background: rgba(255,255,255,.14); padding: .25rem .7rem; border-radius: 999px; }

.app { max-width: 560px; margin: 0 auto; padding: 1.1rem 1.1rem 2rem; }

/* Bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { text-decoration: none; color: var(--muted); font-weight: 700; font-size: .85rem; text-align: center; padding: .9rem 0; position: relative; }
.tabs a.active { color: var(--green); }
.tabs a.active::after { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--gold); border-radius: 0 0 3px 3px; }

/* Hero: the star meter */
.hero { background: var(--green); color: #fff; margin: -1.1rem -1.1rem 1.2rem; padding: 1.6rem 1.1rem 1.8rem; }
.hero h1 { color: #fff; }
.hero .lede { color: #CFE3D6; max-width: 34ch; }
.meter { display: grid; grid-template-columns: 132px 1fr; gap: 1rem; align-items: center; margin-top: 1.2rem; }
.meter > svg { width: 132px; height: 132px; display: block; }
.meter .num { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.meter .num small { font-size: .95rem; font-weight: 600; color: #CFE3D6; margin-left: .25rem; letter-spacing: 0; }
.meter .next { color: #E9D9A8; font-weight: 600; margin-top: .35rem; }
.meter .rank { color: #CFE3D6; font-size: .9rem; margin-top: .35rem; }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem; margin-bottom: .9rem; }
.card.gold { border-color: var(--gold); background: var(--gold-soft); }
.card.green { background: var(--green-soft); border-color: transparent; }
.row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.stack > * + * { margin-top: .6rem; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.pill.gold { background: var(--gold); color: #fff; }
.pill.pending { background: #EEE7D4; color: #7A5B00; }
.pill.approved { background: var(--green-soft); color: var(--green); }
.pill.rejected { background: #F5DDD8; color: var(--danger); }
.pts { font-weight: 800; color: var(--green); white-space: nowrap; }

/* Milestone ladder */
.ladder { list-style: none; padding: 0; margin: 0; }
.ladder li { display: grid; grid-template-columns: 26px 1fr auto; gap: .7rem; align-items: center; padding: .65rem 0; border-top: 1px solid var(--line); }
.ladder li:first-child { border-top: 0; }
.ladder .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; font-size: .8rem; font-weight: 800; }
.ladder li.done .dot { background: var(--gold); border-color: var(--gold); }
.ladder code { font-weight: 800; background: var(--green); color: #fff; padding: .2rem .5rem; border-radius: 6px; letter-spacing: .04em; }

/* Forms */
label { display: block; font-weight: 700; font-size: .9rem; margin: .8rem 0 .3rem; }
input[type=text], input[type=tel], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: .75rem .85rem; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(200,155,42,.55); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: .7rem; border: 1.5px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; background: #fff; }
.seg input:checked + span { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%;
  padding: .85rem 1rem; border-radius: 10px; border: 0; background: var(--green); color: #fff; font-weight: 800; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.gold { background: var(--gold); color: var(--green-deep); }
.btn.ghost { background: transparent; border: 1.5px solid var(--green); color: var(--green); }
.btn.wa { background: #25D366; color: #073B1E; }
.btn.quiet { background: transparent; color: var(--muted); font-weight: 600; }
.btn + .btn { margin-top: .6rem; }
.error { color: var(--danger); font-weight: 600; margin-top: .5rem; }

/* Quiz */
.options { display: grid; gap: .5rem; margin: .8rem 0; }
.options button { text-align: left; padding: .85rem .95rem; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-weight: 600; cursor: pointer; }
.options button:hover { border-color: var(--green); }
.options button.wrong { border-color: var(--danger); color: var(--danger); }

/* Leaderboard */
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .6rem; align-items: center; padding: .6rem .2rem; border-top: 1px solid var(--line); }
.board li:first-child { border-top: 0; }
.board .r { font-weight: 800; color: var(--muted); }
.board li.podium .r { color: var(--gold); }
.board li.you { background: var(--gold-soft); border-radius: 8px; padding-left: .5rem; padding-right: .5rem; }
.board .n { font-weight: 700; }
.board .n small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.filters { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.filters button { border: 1.5px solid var(--line); background: #fff; padding: .4rem .8rem; border-radius: 999px; font-weight: 700; cursor: pointer; }
.filters button.on { background: var(--green); border-color: var(--green); color: #fff; }

/* Scanner */
.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 14%; border: 3px solid var(--gold); border-radius: 12px; pointer-events: none; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.unlock { text-align: center; padding: 1.5rem 1rem; }
.unlock svg { width: 88px; height: 88px; color: var(--gold); }
.unlock .big { font-size: 2.6rem; font-weight: 800; color: var(--green); letter-spacing: -.02em; line-height: 1; margin: .5rem 0 .2rem; }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
