:root {
  --bg: #0a0a0a;
  --ink: #f4f4f2;
  --muted: #8d8d89;
  --soft: #b8b8b3;
  --line: #222;
  --line-strong: #3a3a3a;
  --card: #111;
  --bad: #ff7a66;
  --display: 'Funnel Sans', ui-sans-serif, sans-serif;
  --sans: 'Funnel Sans', ui-sans-serif, sans-serif;
  --mono: 'Funnel Sans', ui-sans-serif, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 90% at 22% 100%, #1b1b1b 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* Film grain over everything, so the flat black has some depth. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a { color: inherit; }
button { font: inherit; }

@keyframes in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes spin { to { transform: rotate(1turn); } }

.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- top bar ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
  padding: 24px clamp(16px, 3vw, 40px) 0;
  animation: in 0.8s var(--ease) both;
}
.top-right { display: inline-flex; align-items: center; gap: 18px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 400 12.5px/1 var(--mono);
  color: var(--muted);
}
.tag:not(:empty)::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.link {
  border: 0;
  background: none;
  color: var(--soft);
  padding: 4px 0;
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
}
.link:hover { color: var(--ink); }

.who {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 500 14px/1 var(--sans);
}
.who[hidden] { display: none; }
.who img { border-radius: 50%; background: #222; }
.who .link { color: var(--muted); }

/* ---------- hero: one column, the same picture → bot in every step ---------- */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vh, 48px) 16px clamp(20px, 3.5vh, 48px);
  text-align: center;
}
/* Hidden until the first render, so a signed-in visitor never sees the signed-out text flash. */
body:not(.ready) .hero, body:not(.ready) .top-right, body:not(.ready) .crowd { visibility: hidden; }
.ready .hero > * { animation: in 0.8s var(--ease) both; }
.ready .hero > :nth-child(2) { animation-delay: 0.06s; }
.ready .hero > :nth-child(3) { animation-delay: 0.12s; }
.ready .hero > :nth-child(4) { animation-delay: 0.18s; }

.title {
  margin: 0;
  max-width: 16ch;
  font: 600 clamp(40px, 5.4vw, 72px) / 0.98 var(--display);
  letter-spacing: -0.045em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.title.long { max-width: 32ch; font-size: clamp(36px, 4.2vw, 56px); }

.lede {
  min-height: 1.5em;
  margin: 14px 0 0;
  max-width: 40ch;
  color: var(--soft);
  font-size: 17px;
  text-wrap: balance;
}
.lede b { color: var(--ink); font-weight: 600; }

.duo {
  --bot: clamp(160px, min(29vh, 50vw), 288px);
  --src: calc(var(--bot) * 0.5);
  margin: clamp(24px, 4.5vh, 44px) 0 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.duo-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 18px);
}
.duo-src, .duo-bot {
  position: relative;
  flex: none;
  border-radius: 50%;
  background: #161616;
  overflow: hidden;
  isolation: isolate;
}
.duo-src { width: var(--src); height: var(--src); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.duo-bot {
  width: var(--bot);
  height: var(--bot);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.duo-arrow {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Each picture change fades a new layer in over the old one. */
.layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 0.7s var(--ease), filter 0.8s var(--ease), transform 0.8s var(--ease);
}
.layer.on { opacity: 1; }

/* Drawing: the plain bot head with a ring running round it. */
.duo-bot::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 60%, rgba(255, 255, 255, 0.95) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  opacity: 0;
  transition: opacity 0.4s;
}
.duo.working .duo-bot::after { opacity: 1; animation: spin 1.1s linear infinite; }
.duo.working .duo-bot .layer.on { animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.55; } }
.duo.blank .duo-bot .layer.on { opacity: 0.9; }

/* Ready but locked: blurred enough to hide the details, clear enough to want it. */
.duo.locked .duo-bot .layer { filter: blur(12px) saturate(1.15); transform: scale(1.12); }
.lock {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.72);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s, transform 0.4s var(--ease);
}
.lock svg { width: 22px; height: 22px; fill: var(--ink); }
.duo.locked .lock { opacity: 1; transform: none; }

/* The moment the bot unlocks. */
.duo.reveal .duo-bot { animation: reveal 0.9s var(--ease) both; }
@keyframes reveal {
  from { filter: blur(14px); transform: scale(0.94); }
  to { filter: none; transform: none; }
}

.duo-cap {
  min-height: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13.5px;
}
.duo-cap a { color: var(--soft); text-decoration: none; }
.duo-cap a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- actions under the pictures ---------- */

.act {
  width: min(400px, 100%);
  margin-top: clamp(20px, 3.5vh, 36px);
}
.step[hidden] { display: none; }

/* ---------- buttons ---------- */

.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: 600 16px/1 var(--sans);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.3s, background 0.3s, color 0.3s;
}
.cta:hover:not(:disabled) { box-shadow: 0 0 48px rgba(255, 255, 255, 0.18); }
.cta:active:not(:disabled) { transform: scale(0.98); }
.cta:disabled { background: #232323; color: #777; cursor: default; }
.cta.busy:disabled {
  background: linear-gradient(100deg, #d9d9d6 30%, #ffffff 50%, #d9d9d6 70%) 0 0 / 300% 100%;
  color: var(--bg);
  animation: sheen 1.6s linear infinite;
}
.cta.passed:disabled { background: var(--ink); color: var(--bg); }
.cta.passed::before {
  content: '';
  width: 12px;
  height: 6px;
  margin: -4px 12px 0 0;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -50% 0; } }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font: 500 14px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}
button.pill { background: none; cursor: pointer; }
.pill:hover { border-color: #777; background: #161616; }
.pill[target='_blank']::after { content: '↗'; font-size: 12px; opacity: 0.55; }
.pill-solid { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.pill-solid:hover { background: #fff; border-color: #fff; }

.cta:focus-visible, .pill:focus-visible, .link:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.cta { gap: 12px; }
.x-logo { width: 18px; height: 18px; fill: currentColor; }
.fine { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.fine a { color: var(--soft); text-underline-offset: 3px; }

.msg {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.msg:empty { display: none; }
.msg.bad { color: var(--bad); }
.msg a { color: var(--ink); text-underline-offset: 3px; }

/* The handle field with the button inside it, like a search bar. */
.handle-form {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 60px;
  padding: 5px 5px 5px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.handle-form:focus-within { border-color: #6a6a6a; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06); }
.handle-field { display: flex; align-items: center; flex: 1; min-width: 0; cursor: text; }
.handle-at { color: var(--muted); font: 500 17px/1 var(--sans); }
.handle-field input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 0 0 3px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: 500 17px/1 var(--sans);
}
.handle-field input::placeholder { color: #66665f; }
.handle-form .cta { width: auto; height: 48px; flex: none; padding: 0 22px; font-size: 15.5px; }
.fine .link { padding: 0; font-size: 13px; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; }

/* The follow step: who to follow, then the button that "checks". */
.follow-box[hidden], .cta[hidden] { display: none; }
.follow-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  text-align: left;
}
.follow-row img { flex: none; border-radius: 50%; background: #222; }
.follow-id { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; font-size: 15px; }
.follow-id b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-id span { color: var(--muted); font-size: 13px; }
.follow-row .pill { height: 44px; padding: 0 22px; font-size: 15px; }

/* After the reveal. */
.share-hint { margin: 12px 0 0; color: var(--ink); font-size: 13.5px; }
.share-hint[hidden] { display: none; }
.sub-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  margin-top: 14px;
}
/* Share and Download side by side: Download filled white, Share in X's own black. */
.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cta-row .cta { padding: 0 16px; }
.cta-x { background: #000; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
.cta-x:hover:not(:disabled) { background: #0d0d0d; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5); }
.dl-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Where the visitor stands: likes and friends who joined, each with its place on the board. */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
  color: inherit;
  text-decoration: none;
}
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: 'icon num' 'icon label' 'icon rank';
  align-items: center;
  column-gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  text-align: left;
  transition: border-color 0.2s;
}
.stats:hover .stat { border-color: var(--line-strong); }
.stat svg {
  grid-area: icon;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--soft);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat b { grid-area: num; font: 600 26px/1 var(--display); letter-spacing: -0.03em; }
.stat-label { grid-area: label; margin-top: 4px; color: var(--soft); font-size: 13.5px; }
.stat-rank { grid-area: rank; margin-top: 2px; color: var(--muted); font-size: 12.5px; }

.next {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  margin: 10px 0 0;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
}
.next svg {
  grid-row: span 2;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.next-goal { color: var(--ink); font-size: 15px; line-height: 1.35; }
.next-goal b { font-weight: 700; }
.next-note { margin-top: 3px; color: var(--muted); font-size: 12.5px; }

/* ---------- already bots: one row drifting by ---------- */

.crowd {
  display: grid;
  gap: 8px;
  padding: 0 0 18px;
  animation: in 0.8s var(--ease) 0.3s both;
}
.crowd[hidden] { display: none; }
.crowd-tag { margin: 0 0 2px; padding: 0 clamp(16px, 3vw, 40px); }
.crowd-row {
  overflow: hidden;
  -webkit-mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.crowd-track {
  display: flex;
  gap: 10px;
  width: max-content;
  animation: marquee var(--marquee, 60s) linear infinite;
}
.crowd:hover .crowd-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

.crowd-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 4px 16px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101010;
  color: var(--soft);
  font: 400 13px/1 var(--mono);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
.crowd-item:hover { border-color: #555; color: var(--ink); }
.crowd-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1a1a1a center / cover no-repeat;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- likes ---------- */

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--soft);
  font: 600 14px/1 var(--sans);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
}
.like-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.like-btn:hover:not(:disabled) { border-color: #777; color: var(--ink); }
.like-btn:active:not(:disabled) { transform: scale(0.94); }
.like-btn[aria-pressed='true'] { border-color: #ff5a6e; color: #ff5a6e; background: rgba(255, 90, 110, 0.08); }
.like-btn[aria-pressed='true'] svg { fill: currentColor; }
.like-btn:disabled { cursor: default; opacity: 0.75; }
.like-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.like-big { height: 46px; padding: 0 20px; font-size: 16px; margin-top: -8px; }
.like-big svg { width: 20px; height: 20px; }

/* ---------- leaderboard page ---------- */

.back { color: var(--soft); text-decoration: none; }
.lb {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 6vh, 64px) 16px 64px;
}
body:not(.ready) .lb { visibility: hidden; }
.ready .lb > * { animation: in 0.7s var(--ease) both; }
.lb .title { max-width: none; }
.lb .lede { margin-top: 12px; }
.lb-cta { width: auto; margin-top: 24px; padding: 0 30px; }
.lb-cta[hidden] { display: none; }

.lb-tabs { display: none; }
.lb-boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 36px;
}
.lb-board {
  padding: 22px 18px 10px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
}
.lb-title { margin: 0 4px; font: 600 22px/1.2 var(--display); letter-spacing: -0.02em; }
.lb-note { margin: 4px 4px 14px; color: var(--muted); font-size: 13.5px; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
}
.lb-row.me { background: rgba(255, 255, 255, 0.04); border-radius: 14px; border-top-color: transparent; }
.lb-rank { color: var(--muted); font: 500 14px/1 var(--mono); text-align: right; }
.lb-row:nth-child(-n + 3) .lb-rank { color: var(--ink); }
.lb-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--soft);
  text-decoration: none;
}
.lb-who:hover { color: var(--ink); }
.lb-img {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1a1a1a center / cover no-repeat;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.lb-name { font: 500 15px/1.2 var(--sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { padding-right: 8px; font: 600 16px/1 var(--sans); }
.lb-empty { padding: 18px 4px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* ---------- share page ---------- */

body.share { display: grid; place-items: center; padding: 32px 16px; }

.share-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  animation: in 0.8s var(--ease) both;
}

.share-card .duo { margin: 0; }

.share-title {
  margin: 0;
  font: 600 clamp(30px, 6vw, 48px) / 1 var(--display);
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.share-card .cta { width: auto; padding: 0 36px; }
.share-sub { margin: -10px 0 0; max-width: 36ch; color: var(--soft); font-size: 16px; }
.share-card .fine { margin: -16px 0 0; }
.share-card .fine a { color: var(--soft); text-underline-offset: 3px; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .top { padding-top: 18px; }
  .top-right { gap: 14px; }
  .who #who-name { display: none; }
  .hero { padding-top: 28px; }
  .title, .title.long { font-size: clamp(34px, 10.5vw, 44px); }
  .lede { font-size: 15.5px; }
  .duo { --bot: min(52vw, 230px); }
  .duo-arrow { width: 18px; height: 18px; }
  .crowd { gap: 8px; padding-bottom: 16px; }
  .crowd-item { height: 44px; gap: 8px; padding-right: 12px; font-size: 12px; }
  .crowd-img { width: 34px; height: 34px; }
  .crowd-row {
    -webkit-mask: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
    mask: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  }
  .lb-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 28px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
  }
  .lb-tab {
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font: 600 14px/1 var(--sans);
    cursor: pointer;
  }
  .lb-tab[aria-selected='true'] { background: var(--ink); color: var(--bg); }
  .lb-boards { display: block; margin-top: 14px; }
  .lb-boards[data-tab='likes'] [data-board='invites'],
  .lb-boards[data-tab='invites'] [data-board='likes'] { display: none; }
  .lb-board { padding: 16px 12px 6px; }
  .lb-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .crowd-row { overflow-x: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
