/* Raronym: one stylesheet, no build step.
   Dark room: a near-black ground, the tier colors lit like specimens under a
   lamp, one amber accent for actions and points. Tokens live in :root so the
   world is one place to change. Every tier color clears 7:1 on the ground. */
:root {
  --bg: #0c100e;
  --card: #141a17;
  --ink: #e9efe7;
  --muted: #a9b4aa;
  --line: #27302b;
  --accent: #f2a65a;
  --accent-ink: #1a1208;
  --input: #0f1412;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  --glow: 0 0 0 1px rgba(242, 166, 90, .4), 0 8px 28px rgba(242, 166, 90, .26);
  --t0: #a8a196; /* Sibling */
  --t1: #7fc46b; /* Cousin */
  --t2: #6ab0a8; /* Second Cousin: lichen */
  --t3: #6ea0ef; /* Distant Cousin */
  --t4: #b494d6; /* Long-Lost Relative: heather */
  --miss: #ef7b72;
  --radius: 18px;
  --serif: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: var(--serif); /* one voice throughout, optical sizing on */
  /* Motion: strong ease-out for anything entering; durations stay short. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-press: 120ms;
  --dur-ui: 200ms;
  --dur-reveal: 320ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  /* Let the page bounce at its ends (iOS, Mac trackpads). "contain" keeps the
     bounce but stops the gesture from turning into pull-to-refresh or a
     sideways back-swipe in browsers that honor it. */
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
}
/* During a timed round, no overscroll at all: a pull-to-refresh there would
   reset the clock. The round screen is short, so nothing is lost. */
html.inround { overscroll-behavior-y: none; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  caret-color: var(--accent);
}
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* Background layer: generated SVG behind everything, never interactive. */
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; color: var(--ink); opacity: .1; }
.bg-roots { top: auto; height: 70vh; }
.app {
  position: relative; z-index: 1;
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }

/* Header */
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 6px 2px 14px;
}
.brand {
  font-family: var(--serif); font-optical-sizing: auto;
  font-size: 30px; font-weight: 600; letter-spacing: -.015em; margin: 0; line-height: 1.1;
}
/* Display sizes: heavy and tight, the Dark room voice. */
.brand, .verdict .vword, .card h2, .score { font-weight: 800; letter-spacing: -.035em; }
.prompt { font-weight: 800; }
.brand small { font-family: var(--serif); font-size: 13px; color: var(--muted); font-weight: 400; display: block; margin-top: 2px; letter-spacing: 0; }
.daymeta { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 14px;
}
.card h2 { font-family: var(--serif); font-optical-sizing: auto; font-size: 26px; margin: 0 0 10px; font-weight: 600; letter-spacing: -.01em; }
.card p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* Buttons: press feedback on :active (works for touch), hover only for pointers that can hover. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 999px; padding: 12px 22px;
  font-weight: 600; font-size: 17px; min-height: 48px; letter-spacing: .005em;
  transition: transform var(--dur-press) var(--ease-out), filter var(--dur-ui) ease;
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.06); }
  .btn.secondary:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); filter: none; }
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btnrow .btn { flex: 1; white-space: nowrap; }
@media (max-width: 420px) { .btnrow .btn { flex: 1 1 100%; } }

/* Tier glyph: tree rings around a pith, one ring per generation back to the
   shared root. Drawn in currentColor wherever a tier is named. */
.glyph { display: inline-block; vertical-align: -4px; margin-right: 7px; overflow: visible; }
.glyph .ring { fill: none; stroke: currentColor; stroke-width: 2; }
.glyph .ring.outer { stroke-width: 2.8; }
.glyph .ring.miss { stroke-width: 2.2; stroke-dasharray: 3 3.5; opacity: .9; }
.glyph .pith { fill: currentColor; }
.glyphrow { display: flex; justify-content: center; gap: 14px; margin: 10px 0 14px; }
.glyphrow .g .glyph { margin: 0; vertical-align: 0; }

/* Round */
.roundhead { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.prompt {
  font-family: var(--serif); font-optical-sizing: auto;
  font-size: clamp(38px, 10.5vw, 56px);
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-align: center;
  margin: 10px 0 4px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.root { text-align: center; color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.root em { font-style: italic; color: var(--ink); }
.timer { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 18px; }
.timer > div {
  height: 100%; width: 100%; background: var(--accent); border-radius: 999px;
  transform-origin: left center; transform: scaleX(1);
  transition: transform .1s linear, background var(--dur-ui) ease;
}
.timer.low > div { background: var(--miss); }
.timerlabel { text-align: right; font-size: 13px; color: var(--muted); margin-top: -14px; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.answerform { display: flex; gap: 8px; }
.answerform input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 20px;
  padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--input); color: var(--ink);
  outline: none;
  text-transform: lowercase;
  transition: border-color var(--dur-ui) ease;
}
.answerform input:focus { border-color: var(--accent); }
.answerform input::placeholder { color: var(--muted); opacity: 1; }
.feedback { min-height: 48px; margin-top: 12px; font-size: 15px; padding: 10px 12px; border-radius: 10px; background: transparent; }
.feedback.bad { background: color-mix(in srgb, var(--miss) 12%, transparent); color: var(--ink); }
.feedback.info { background: color-mix(in srgb, var(--t3) 12%, transparent); }
.shake { animation: shake 300ms var(--ease-out); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 55%{transform:translateX(5px)} 80%{transform:translateX(-3px)} }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; text-align: center; }

/* Reveal */
.result { text-align: center; padding: 2px 0 14px; }
.verdict .vword { font-family: var(--serif); font-optical-sizing: auto; font-size: 34px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; margin-bottom: 2px; overflow-wrap: anywhere; }
.verdict .vcounted { font-size: 14px; color: var(--muted); margin: -2px 0 6px; }
.verdict .vcounted b { color: var(--ink); font-weight: 600; }
.verdict .vbranch { font-size: 14px; color: var(--muted); margin: -2px 0 6px; }
.verdict .vtitle { font-family: var(--sans); font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; display: inline-flex; align-items: center; }
.verdict .vtitle .glyph { margin-right: 10px; vertical-align: 0; }
.verdict.miss .vtitle { color: var(--miss); font-size: 26px; margin-top: 6px; }
.verdict .vpts { font-size: 18px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.verdict .vpts b { font-size: 30px; font-weight: 800; }
.verdict .vline { margin: 4px 0 6px; color: var(--muted); font-size: 15px; }

/* The rings stage. The pith is the shared root; rings form outward one per
   generation, each lighting its label as it closes. Timing: --step per ring,
   --trunk for the whole set, --kk each ring's index, --c its circumference. */
.climb { margin: 4px 0 6px; cursor: pointer; }
.climb svg { display: block; width: 100%; height: auto; max-height: 270px; overflow: visible; font-family: var(--serif); }
.climb .pith { fill: var(--accent); filter: url(#ringglow); }
.climb .basewd { font-size: 11px; font-style: italic; fill: var(--muted); transform: translateY(16px); }
.climb .ring { fill: none; stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 3 4; }
.climb .lead { stroke: var(--line); stroke-width: 1; }
.climb .lbl { font-size: 12px; fill: var(--muted); }
.climb .band { font-size: 10px; fill: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.climb .rung.pass .ring { stroke: currentColor; stroke-width: 2.5; stroke-dasharray: var(--c); stroke-dashoffset: var(--c); transform: rotate(-90deg); transform-box: fill-box; transform-origin: center; }
.climb .rung.pass .lead { stroke: currentColor; }
.climb .rung.pass .lbl { fill: currentColor; font-weight: 600; }
.climb .rung.pass .band { fill: var(--muted); }

/* Playing: rings draw one after another; labels light as each ring closes. */
.reveal.live .climb .rung.pass .ring { animation: draw var(--step) linear both; animation-delay: calc((var(--kk) - 1) * var(--step)); }
.reveal.live .climb .rung.pass .lead, .reveal.live .climb .rung.pass .lbl, .reveal.live .climb .rung.pass .band { animation: light 200ms var(--ease-out) both; animation-delay: calc(var(--kk) * var(--step) - 80ms); }
.reveal.live .result.enter-lead { animation-delay: var(--after); }
.reveal.live .tiergroup { animation-delay: calc(var(--after) + 60ms + var(--i, 0) * 35ms); }
.reveal.live .enter-fade { animation-delay: calc(var(--after) + 140ms); }
/* Finished (or skipped): final state, no waiting. */
.reveal.done .climb .rung.pass .ring { stroke-dashoffset: 0; }
.reveal.done .climb .rung.pass .lead, .reveal.done .climb .rung.pass .lbl, .reveal.done .climb .rung.pass .band { animation: none; }
.reveal.done .result, .reveal.done .tiergroup, .reveal.done .enter-fade { animation-duration: 0ms; animation-delay: 0ms; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes light { from { opacity: .35; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }

.result .yours { font-family: var(--serif); font-optical-sizing: auto; font-size: 38px; font-weight: 700; margin: 4px 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.result .yours.missed { color: var(--miss); font-size: 26px; }
.badge {
  display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px;
  font-weight: 600; font-size: 14px; margin: 4px 0; white-space: nowrap;
  background: color-mix(in srgb, currentColor 13%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 42%, transparent);
}
.badge.t0 { color: var(--t0); } .badge.t1 { color: var(--t1); } .badge.t2 { color: var(--t2); }
.badge.t3 { color: var(--t3); } .badge.t4 { color: var(--t4); } .badge.miss { color: var(--miss); }
.points { font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; margin: 8px 0 2px; }
.points small { font-size: 16px; font-weight: 500; color: var(--muted); }
.crowdline { font-size: 13px; color: var(--muted); }
/* Rarity block on the reveal: family strip, then the plain-language line. */
.rarity { margin: 12px auto 8px; padding-top: 12px; border-top: 1px solid var(--line); max-width: 340px; }
.rarity .strip { display: block; width: 100%; height: auto; overflow: visible; }
.rarity .seg { stroke: currentColor; stroke-width: 3; stroke-linecap: round; opacity: .7; }
.rarity .dot { fill: var(--muted); opacity: .6; }
.rarity .you .halo { fill: none; stroke: var(--accent); stroke-width: 2; }
.rarity .you .core { fill: var(--accent); }
.rarity .cap { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .04em; color: var(--muted); margin-top: 2px; }
.rarity .rline { font-size: 15px; line-height: 1.4; color: var(--ink); margin-top: 8px; text-wrap: balance; }
.rarity .rline em { font-style: italic; }
/* Your dot travels from the everyday end to its place while the points count up. */
.reveal.live .rarity .you { animation: slidein 360ms var(--ease-out) both; animation-delay: calc(var(--after) - 100ms); }
.reveal.done .rarity .you { animation: none; }
@keyframes slidein { from { transform: translateX(var(--from)); } }

.tree h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 6px; display: flex; align-items: center; gap: 2px; font-weight: 600; }
.tree h3 .pts { margin-left: auto; font-weight: 500; color: var(--muted); letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  user-select: none; -webkit-user-select: none;
}
.chip.you { border-width: 2px; font-weight: 700; }
.chip.t4 { border-color: var(--t4); } .chip.t3 { border-color: var(--t3); } .chip.t2 { border-color: var(--t2); }
.chip.t1 { border-color: var(--t1); } .chip.t0 { border-color: var(--t0); }
.chip .via { font-size: 12px; color: var(--muted); margin-left: 5px; }
.others h3 { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; }
.others .chip { display: inline-flex; align-items: center; border-color: currentColor; }
.others .chip .glyph { margin-right: 5px; vertical-align: 0; }
.others .chip .via { color: var(--muted); }
.notes { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.notes h4 { margin: 0 0 8px; font-family: var(--serif); font-optical-sizing: auto; font-size: 18px; font-weight: 600; }
.notes ul { margin: 0; padding-left: 18px; font-size: 15px; }
.notes li { margin-bottom: 6px; }
.source { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* Done */
.score { font-size: 60px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; margin: 6px 0 8px; letter-spacing: -.02em; }
.score small { font-size: 18px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.rounds { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0; }
.rounds td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.rounds td:first-child { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; font-size: 13px; }
.rounds td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
/* Population curve on the score screen */
.population { margin: 6px 0 10px; text-align: center; }
.pophead { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.popnote { font-size: 13px; color: var(--muted); }
.curve { display: block; width: 100%; max-width: 360px; height: auto; margin: 2px auto; overflow: visible; }
.curve .line { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.curve .area { fill: var(--accent); opacity: .22; }
.curve .axis { stroke: var(--line); stroke-width: 1; }
.curve .you { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; }
.curve .youdot { fill: var(--accent); }
.curve text { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.card p.statline { text-align: center; color: var(--muted); font-size: 15px; margin: 32px 0 4px; font-variant-numeric: tabular-nums; }
.statline b { color: var(--ink); font-weight: 600; }
.testlinks { margin-top: 10px; }
.testlinks a { color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 8px);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-ui) var(--ease-out), transform var(--dur-ui) var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* How to play */
.howto ol { padding-left: 20px; margin: 0 0 12px; }
.howto li { margin-bottom: 6px; }
.tierlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.card p.tiernote { color: var(--ink); margin: 0 0 14px; line-height: 1.45; }

/* Motion. One authored moment: the reveal. The word leads, the tier groups
   follow in a short overlapping stagger, the notes only fade. Everything is
   clickable from the first frame; nothing here blocks input. */
/* Screen changes: the outgoing card lifts away, the next rises into place.
   Exit is short, entrance longer, and they overlap by a frame or two. */
.stage.leave { animation: leave 170ms var(--ease-out) both; pointer-events: none; }
.stage.enter { animation: arrive 360ms var(--ease-out) both; }
.stage.enter:not(.reveal-stage) .enter-prompt,
.stage.enter:not(.reveal-stage) .enter-lead,
.stage.enter:not(.reveal-stage) .enter-fade { animation: none; }   /* one entrance per container */
@keyframes leave { to { opacity: 0; transform: translateY(-18px); } }
@keyframes arrive { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(var(--rise, 12px)); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.enter-lead { animation: rise var(--dur-reveal) var(--ease-out) both; --rise: 12px; }
.enter-prompt { animation: rise 220ms var(--ease-out) both; --rise: 8px; }
.tiergroup { animation: rise 260ms var(--ease-out) both; --rise: 6px; animation-delay: calc(50ms + var(--i, 0) * 35ms); }
.enter-fade { animation: fade 260ms ease both; animation-delay: 120ms; }
@media (prefers-reduced-motion: reduce) {
  .enter-lead, .enter-prompt, .tiergroup, .enter-fade { animation: fade 180ms ease both; animation-delay: 0ms !important; }
  .stage.leave, .stage.enter { animation: fade 160ms ease both; }
  .climb .rung.pass .ring { stroke-dashoffset: 0 !important; animation: none !important; }
  .climb .rung .lead, .climb .rung .lbl, .climb .rung .band { animation: none !important; opacity: 1 !important; }
  .shake { animation: none; }
  .btn, .toast, .timer > div { transition-duration: 0ms; }
}

/* Dark room light: reached rings glow in their tier color; actions glow amber. */
.climb .rung.pass .ring { filter: url(#ringglow); }
.btn:not(.secondary) { box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 18px rgba(0, 0, 0, .45); }
.verdict .vpts b { color: var(--accent); }
.card { border-color: rgba(233, 239, 231, .08); }
