@font-face {
  font-family: 'Anton';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/anton-400.woff2) format('woff2');
}
@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/worksans-var.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/plexmono-400.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/plexmono-500.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/plexmono-600.woff2) format('woff2');
}

:root {
  --ink: #12181a;
  --surface: #1b2420;
  --surface-raised: #212c27;
  --paper: #f1ecdd;
  --muted: #93a29a;
  --brass: #d9a94e;
  --brass-ink: #2a1f0c;
  --felt: #4e9c86;
  --band: #c4472e;
  --line: #2b3630;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ink: #1a211d;
  --surface: #fbfaf4;
  --surface-raised: #ffffff;
  --paper: #1a211d;
  --muted: #6b7770;
  --brass: #a8791f;
  --brass-ink: #fff8ea;
  --felt: #2e7a67;
  --band: #a63a22;
  --line: #dcd9c8;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Work Sans', -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar { padding: 14px 20px 8px; display: flex; align-items: baseline; justify-content: space-between; }
.brand { font-family: 'Anton', sans-serif; font-weight: 400; font-size: 21px; letter-spacing: .01em; }
.brand b { color: var(--brass); font-weight: 400; }

#views { flex: 1; padding: 4px 16px 100px; }
.view { display: none; flex-direction: column; gap: 14px; }
.view.active { display: flex; }

/* ---- ticket card w/ perforated top edge ---- */
.card, .earn-card, .friend-empty, .card.stats-grid, .row-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card {
  padding: 20px 18px 18px;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  top: -6px; left: 10px; right: 10px;
  height: 12px;
  background-image: radial-gradient(circle at 6px 6px, var(--ink) 4.5px, transparent 4.6px);
  background-size: 16px 12px;
  background-repeat: repeat-x;
}

.label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* odometer balance */
.balance-row { display: flex; align-items: baseline; gap: 3px; margin-top: 8px; }
.balance-row .coin { display: none; }
.odo-digits { display: flex; gap: 3px; }
.odo-digits span {
  font-family: 'Anton', sans-serif;
  font-size: 40px;
  line-height: 1;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 3px 2px;
  min-width: 24px;
  text-align: center;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}
.odo-digits span.dot { border: none; background: none; min-width: 8px; color: var(--muted); font-size: 30px; padding: 0; }
.balance-row .unit {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--felt);
  font-weight: 600;
  letter-spacing: .06em;
  margin-left: 8px;
  align-self: center;
}

.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: 16px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brass); border-radius: 3px; transition: width .3s; }
.hint { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* earn hero */
.earn-card {
  background: linear-gradient(155deg, var(--felt), #2f6e5f);
  color: #eef7f3;
  padding: 20px 18px;
  position: relative;
}
.earn-card::before {
  content: "";
  position: absolute; top: -6px; left: 10px; right: 10px; height: 12px;
  background-image: radial-gradient(circle at 6px 6px, var(--ink) 4.5px, transparent 4.6px);
  background-size: 16px 12px; background-repeat: repeat-x;
}
.earn-card .label { color: rgba(238,247,243,.75); }
.earn-card .big { font-family: 'Anton', sans-serif; font-size: 32px; color: #fff; margin-top: 6px; }
.earn-card .big small { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 500; opacity: .85; margin-left: 6px; }
.earn-card .meta { font-family: 'IBM Plex Mono', monospace; font-size: 11px; margin-top: 6px; opacity: .9; letter-spacing: .02em; }
.earn-card .icon {
  position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.14); border: 1px dashed rgba(255,255,255,.5);
  display: flex; align-items: center; justify-content: center; font-family: 'Anton', sans-serif; font-size: 16px; color: #eef7f3;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 15px; font-family: 'Work Sans', sans-serif; font-size: 14.5px; font-weight: 700;
  cursor: pointer; width: 100%;
}
.btn-white { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; margin-top: 16px; }
.btn-rust { background: var(--brass); color: var(--brass-ink); }
.btn-rust:active { filter: brightness(.94); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row-card {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; cursor: pointer;
}
.row-card .ico {
  width: 34px; height: 34px; border-radius: 8px; background: var(--surface-raised); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--felt); flex: none;
}
.row-card .txt { flex: 1; min-width: 0; }
.row-card .txt .t { font-weight: 700; font-size: 13.5px; }
.row-card .txt .s { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.row-card .chev { color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.stats-grid .stat { padding: 14px 6px; text-align: center; }
.stats-grid .stat:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
.stats-grid .stat:not(:nth-child(3n)) { border-right: 1px solid var(--line); }
.stats-grid .v { font-family: 'Anton', sans-serif; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats-grid .k { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; margin-top: 3px; }

.toggle-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.toggle-row .t { font-weight: 700; font-size: 13.5px; }
.toggle-row .s { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--line); flex: none; border: none; cursor: pointer; }
.switch.on { background: var(--felt); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); transition: left .15s; }
.switch.on::after { left: 21px; }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 11px; border-radius: 7px; border: none; background: none; color: var(--muted); cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}
.seg button.active { background: var(--brass); color: var(--brass-ink); font-weight: 600; }

.progress-count { font-family: 'Anton', sans-serif; font-size: 32px; }
.progress-count small { font-family: 'IBM Plex Mono', monospace; font-size: 15px; color: var(--muted); font-weight: 500; }
.friend-empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.friend-empty b { color: var(--paper); font-family: 'Anton', sans-serif; font-weight: 400; font-size: 16px; display: block; margin-bottom: 4px; }
.friend-row { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.friend-row:last-child { border-bottom: none; }
.friend-row .q { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--felt); }
.friend-row .q.no { color: var(--muted); font-weight: 400; }

.copy-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--line); border-radius: 10px; padding: 13px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; background: none; color: var(--paper); cursor: pointer;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface); border-top: 1px dashed var(--line);
  padding: 8px 6px calc(env(safe-area-inset-bottom) + 8px);
}
.tab { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 0; cursor: pointer; }
.tab span:first-child { font-size: 16px; font-family: 'Anton', sans-serif; }
.tab.active { color: var(--brass); }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px);
  background: var(--surface-raised); color: var(--paper); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.field {
  width: 100%; padding: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-raised);
  color: var(--paper); font-family: 'IBM Plex Mono', monospace; font-size: 13px; margin-top: 8px;
}
.field::placeholder { font-family: 'Work Sans', sans-serif; color: var(--muted); }
