:root {
  --ground: #F5F2F8;
  --surface: #FFFFFF;
  --sunk: #ECE7F1;
  --ink: #221A2C;
  --muted: #6F6679;
  --line: #E2DBE8;
  --a: #FF5A4E;
  --a-soft: #FFE4E1;
  --b: #4059F5;
  --b-soft: #E2E7FF;
  --joint: #FFB020;
  --joint-soft: #FFF1D2;
  --joint-ink: #6E4300;
  --ok: #17865A;
  --ok-soft: #DDF3E8;
  --miss: #B8323A;
  --miss-soft: #FBE3E4;

  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141019;
    --surface: #1F1926;
    --sunk: #2A2233;
    --ink: #F2EDF6;
    --muted: #A69EB0;
    --line: #342B3E;
    --a: #FF6D62;
    --a-soft: #3B2024;
    --b: #7488FF;
    --b-soft: #1F2546;
    --joint: #FFB84A;
    --joint-soft: #33260E;
    --joint-ink: #FFD48A;
    --ok: #4FD196;
    --ok-soft: #16301F;
    --miss: #FF8A90;
    --miss-soft: #3A1B1E;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--joint); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* partner color scopes */
.p-a { --p: var(--a); --p-soft: var(--a-soft); }
.p-b { --p: var(--b); --p-soft: var(--b-soft); }
.me-a { --me: var(--a); }
.me-b { --me: var(--b); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--p); flex: none; }

/* ---------- type ---------- */
.display {
  font-family: var(--display);
  font-variation-settings: "wdth" 85, "opsz" 48;
  font-weight: 750;
  font-size: clamp(30px, 8.5vw, 38px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { margin: 0; color: var(--muted); font-size: 17px; max-width: 34ch; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
.label, .field label { font-size: 14px; font-weight: 600; margin: 0; }
.optional { font-weight: 400; color: var(--muted); }

/* ---------- layout ---------- */
.shell, .gate {
  max-width: 480px;
  margin: 0 auto;
  padding-inline: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.shell { padding-block: calc(env(safe-area-inset-top) + 20px) calc(env(safe-area-inset-bottom) + 112px); }
.gate { padding-block: calc(env(safe-area-inset-top) + 40px) 48px; gap: 18px; }
.top { display: flex; flex-direction: column; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.split { display: grid; grid-template-columns: auto 1fr; gap: 16px 20px; }
.split .stepper input { width: 64px; }
.split .chips { flex-wrap: nowrap; }
.field { display: flex; flex-direction: column; gap: 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 18px; margin-bottom: 20px; }
.mark { width: 40px; height: 24px; }
.mark circle { fill: none; stroke: var(--p); stroke-width: 4; }

/* ---------- controls ---------- */
input:not([type=file]), textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  resize: vertical;
}
input:focus, textarea:focus { outline: none; border-color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-weight: 650;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--ink); color: var(--ground); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; background: var(--sunk); }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.danger { color: var(--miss); }
.ico { width: 20px; height: 20px; }
.link { background: none; border: 0; padding: 6px 0; color: var(--muted); font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
}
.chip.on { background: var(--ink); color: var(--ground); border-color: var(--ink); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { text-align: center; padding-inline: 4px; font-variant-numeric: tabular-nums; }
.step {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.step:disabled { opacity: 0.4; }
.step-val { font-family: var(--display); font-weight: 700; font-size: 26px; min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--muted);
  vertical-align: 2px;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.miss { background: var(--miss-soft); color: var(--miss); }

/* ---------- gate ---------- */
.who-pick { display: grid; gap: 12px; margin-top: 8px; }
.who {
  display: flex; align-items: center; gap: 14px;
  padding: 22px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--p);
  background: var(--p-soft);
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  cursor: pointer;
  text-align: left;
}
.who .swatch { width: 16px; height: 16px; }

/* ---------- home ---------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--p-soft);
  border-radius: 16px;
  padding: 12px 12px 12px 16px;
  animation: wiggle 0.6s ease 0.2s 2;
}
.banner p { margin: 0; font-size: 15px; }
.banner .btn { background: var(--surface); }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }

.hero { display: flex; flex-direction: column; gap: 18px; }
.rings { width: 100%; max-width: 380px; margin: 0 auto; overflow: visible; }
.rings circle { fill: none; stroke-width: 15; }
.rings .track { stroke: var(--sunk); }
.rings .arc { stroke: var(--p); stroke-linecap: round; transition: stroke-dasharray 0.8s cubic-bezier(.2,.8,.2,1); mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .rings .arc { mix-blend-mode: screen; } }
.ring-num { font-family: var(--display); font-weight: 750; font-size: 40px; fill: var(--ink); font-variant-numeric: tabular-nums; }
.ring-goal { font-size: 18px; font-weight: 600; fill: var(--muted); }
.ring-streak { font-family: var(--display); font-weight: 800; font-size: 22px; fill: var(--joint-ink); }
.ring-streak-label { font-size: 9px; font-weight: 800; letter-spacing: 0.12em; fill: var(--joint-ink); }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.legend-col { display: flex; flex-direction: column; gap: 6px; }
.legend-name { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 650; }
.you { font-size: 12px; color: var(--muted); font-weight: 500; }
.legend-stat { margin: 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dots { display: grid; grid-template-columns: repeat(7, minmax(0, 22px)); gap: 3px; }
.dot {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--sunk);
  font-size: 10px; font-weight: 700;
  color: var(--muted);
}
.dot.on { background: var(--p); color: #fff; }
.dot.today { box-shadow: 0 0 0 2px var(--ground), 0 0 0 3.5px var(--ink); }

.promise {
  background: var(--p-soft);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.promise-text { margin: 0; font-size: 17px; }
.waiting { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }

/* stakes: a torn ticket stub */
.ticket {
  position: relative;
  background: var(--joint-soft);
  color: var(--ink);
  border-radius: 16px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  border: 1.5px dashed color-mix(in srgb, var(--joint) 70%, transparent);
}
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 18px; height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--ground);
}
.ticket::before { left: -10px; }
.ticket::after { right: -10px; }
.ticket .eyebrow { color: var(--joint-ink); }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ticket-when { margin: 0; font-size: 13px; color: var(--joint-ink); }
.ticket-form { display: flex; gap: 8px; }
.ticket-form input { background: var(--surface); border-color: transparent; font-weight: 600; }
.ticket-form .btn { min-height: 48px; background: var(--ink); color: var(--ground); }
.ticket .hint { color: var(--joint-ink); opacity: 0.85; }

.recap { display: flex; flex-direction: column; gap: 12px; border-top: 1.5px solid var(--line); padding-top: 20px; }
.recap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.recap-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.recap-num { margin: 0; font-family: var(--display); font-weight: 750; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.recap-num span { font-size: 18px; color: var(--muted); }
.recap-line { margin: 0; font-size: 16px; }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; gap: 28px; }
.post { display: flex; flex-direction: column; gap: 10px; }
.post-head { display: flex; align-items: center; gap: 8px; }
.post-head p { margin: 0; flex: 1; font-size: 15px; min-width: 0; }
.post-head time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  margin: -8px -8px -8px -2px;
  border: 0; border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--miss-soft); color: var(--miss); }
.post-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--sunk);
  border: 3px solid var(--p);
}
.post-note { margin: 0; font-size: 16px; }
.post-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reacts { display: flex; gap: 6px; }
.react {
  position: relative;
  display: inline-flex; align-items: center; gap: 3px;
  height: 38px; padding: 0 10px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 17px;
  cursor: pointer;
}
.react.on { border-color: var(--me); }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--p); }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.comments li { font-size: 15px; }
.comments strong { color: var(--p); font-weight: 700; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { padding: 9px 14px; border-radius: 999px; font-size: 15px; }
.pinky {
  background: var(--p-soft);
  border-radius: var(--radius);
  padding: 16px;
  align-items: flex-start;
}
.pinky .post-head { width: 100%; }
.empty { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; color: var(--muted); }
.empty p { margin: 0; }

/* ---------- log ---------- */
.shot {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sunk);
  border: 3px solid var(--me);
}
.shot img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.shot .over { position: absolute; right: 12px; bottom: 12px; background: var(--surface); }
.shot-empty {
  aspect-ratio: 4 / 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 20px;
}
.shot-empty p { margin: 0; color: var(--muted); }
.promise-ask { display: flex; flex-direction: column; gap: 10px; border-top: 1.5px solid var(--line); padding-top: 20px; }
.promise-ask > p { margin: 0; }

/* ---------- us ---------- */
.settings { display: flex; flex-direction: column; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 16px;
  border-bottom: 1.5px solid var(--line);
}
.setting:first-child { padding-top: 0; }
.setting-name { margin: 0; font-weight: 650; }
.totals { margin: 0; display: flex; gap: 14px; font-family: var(--display); font-weight: 750; font-size: 26px; font-variant-numeric: tabular-nums; }
.totals span { color: var(--p); }

/* ---------- bets ---------- */
.section { display: flex; flex-direction: column; gap: 12px; }
.score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; }
.score-col { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.score-col:last-child { align-items: flex-end; }
.score-num {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 78, "opsz" 96;
  font-weight: 800;
  font-size: 72px;
  line-height: 0.9;
  color: var(--p);
  font-variant-numeric: tabular-nums;
}
.score-vs { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bet {
  background: var(--surface);
  border: 1.5px dashed color-mix(in srgb, var(--joint) 65%, transparent);
  border-radius: 16px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.bet.needs { background: var(--joint-soft); }
.bet-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.15; text-wrap: balance; }
.bet-meta { margin: 0; font-size: 14px; color: var(--muted); }
.bet-meta strong, .bet-status strong { color: var(--ink); font-weight: 650; }
.bet-by { display: inline-flex; align-items: center; gap: 5px; }
.bet-status { margin: 0; font-size: 15px; }
.bet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn.claim { background: var(--p-soft); border-color: var(--p); }
.debt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; border-bottom: 1.5px solid var(--line); }
.debt:first-child { padding-top: 0; }
.debt p { margin: 0; }
.debt-who { font-weight: 650; }
.debt-from { font-size: 13px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.history strong { color: var(--ink); font-weight: 600; }
.link.inline { padding: 0; font-size: inherit; color: inherit; font-weight: 650; }

/* ---------- notification toggles ---------- */
.toggle { cursor: pointer; }
.toggle > div { flex: 1; min-width: 0; }
/* input.switch outranks the general `input:not([type=file])` text-field rule above */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 50px; height: 30px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--sunk);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 23px; height: 23px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.15s ease;
}
.switch:checked { background: var(--ok); border-color: var(--ok); }
.switch:checked::before { transform: translateX(20px); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -12px rgb(34 26 44 / 0.35);
  z-index: 10;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0;
  padding: 6px 0;
  color: var(--muted);
  font-size: 11px; font-weight: 650;
  cursor: pointer;
  border-radius: 999px;
}
.tab.on { color: var(--ink); }
.tab { position: relative; }
.badge {
  position: absolute;
  top: 0;
  left: calc(50% + 6px);
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--joint);
  color: #2B1B00;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
}
.tab.log {
  justify-self: center;
  width: 54px; height: 54px;
  background: var(--me);
  color: #fff;
  border-radius: 50%;
  justify-content: center;
}
.tab.log .big { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- toast & boot ---------- */
#toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  transform: translate(-50%, -140%);
  max-width: calc(100% - 32px);
  background: var(--ink);
  color: var(--ground);
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 550;
  transition: transform 0.25s ease;
  z-index: 20;
}
#toast.show { transform: translate(-50%, 0); }
.boot { min-height: 100vh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
