/* Layout: blue scorecard screens (home, result) bookend a quiet white article page;
   a sticky scoreboard rides on top while you play. */
:root {
  --brand: #2342FF;
  --brand-deep: #1630D4;
  --on-brand: #FFFFFF;
  --on-brand-dim: rgba(255, 255, 255, .72);
  --on-brand-line: rgba(255, 255, 255, .3);
  --paper: #FFFFFF;
  --ink: #0E1122;
  --muted: #5B6180;
  --line: #E4E7F3;
  --surface: #F2F4FD;
  --link: #2342FF;
  --scrim: rgba(6, 8, 24, .55);
  --up: #16A34A;
  --same: #EAB308;
  --down: #EF4444;

  /* Wikipedia's own type: its title face, Linux Libertine (served as Libertinus, its open successor),
     and the system sans its mobile site reads in */
  --f-display: "Libertinus Serif", "Linux Libertine", Georgia, Times, serif;
  --f-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Lato, Helvetica, Arial, sans-serif;
  --f-read: var(--f-ui);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #1D34CF;
    --brand-deep: #13238F;
    --paper: #0B0D17;
    --ink: #E8EBF8;
    --muted: #969DBA;
    --line: #22273C;
    --surface: #151A2C;
    --link: #93A4FF;
    --up: #22C55E;
    --same: #FACC15;
    --down: #F87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #1D34CF;
  --brand-deep: #13238F;
  --paper: #0B0D17;
  --ink: #E8EBF8;
  --muted: #969DBA;
  --line: #22273C;
  --surface: #151A2C;
  --link: #93A4FF;
  --up: #22C55E;
  --same: #FACC15;
  --down: #F87171;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
html[data-view="home"], html[data-view="end"], html[data-view="past"], html[data-view="day"] { background: var(--brand); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html[data-view="home"] body, html[data-view="end"] body, html[data-view="past"] body, html[data-view="day"] body { background: var(--brand); color: var(--on-brand); }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 6px; }
.screen :focus-visible { outline-color: var(--on-brand); }

/* ---------- Scorecard screens ---------- */
.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-block: calc(18px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.topline { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
/* WIKISPEED.IO in capitals, the W standing taller than the rest */
.wordmark {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.1875rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: var(--on-brand-dim);
}
.wordmark .w { font-size: 1.45em; letter-spacing: .02em; }
.meta {
  font-weight: 600;
  font-size: .9375rem;
  color: var(--on-brand-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* On a narrow phone the weekday goes, so the header stays on one line beside the wordmark */
@media (max-width: 419px) { .meta .wd { display: none; } }
/* Section headings set like Wikipedia's: the title face over a hairline rule */
.label {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--on-brand);
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--on-brand-line);
}
/* "From" and "To", and the line over a card's title */
.pt .label, .sheet .label {
  font-style: italic;
  font-size: 1.1875rem;
  color: var(--on-brand-dim);
  margin: 0;
  padding: 0;
  border: 0;
}

.hole { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.pt { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; align-items: start; }
.pt-text { min-width: 0; }
.thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--on-brand-line) center / cover no-repeat;
  box-shadow: 0 0 0 3px var(--on-brand);
  display: grid;
  place-items: center;
  font-family: var(--f-display);
  font-size: 1.75rem;
  color: var(--on-brand);
}
.pt h2 {
  width: fit-content;
  max-width: 100%;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 10.5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -.01em;
  margin: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.pt .d { margin: 8px 0 0; color: var(--on-brand-dim); font-size: .95rem; line-height: 1.35; min-height: 1.35em; }
.link-line {
  position: relative;
  margin: 12px 0 12px 26px;
  padding: 16px 0 16px 37px;
  min-height: 72px;
  display: flex;
  align-items: center;
}
.link-line::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  border-left: 3px dotted var(--on-brand-dim);
}
.par {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: .9375rem;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  background: var(--on-brand);
  color: var(--brand);
}
/* Home's one entrance: From lands, the dotted link traces itself down, par drops onto it, To lands */
#home .pt { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
#home .link-line::before { animation: trace .5s cubic-bezier(.5, 0, .3, 1) .22s both; }
#home .par { animation: pop .4s cubic-bezier(.3, 1.5, .5, 1) .5s both; }
#home .pt + .link-line + .pt { animation-delay: .62s; }
/* Until today's pair arrives the hole stays empty; showing it again replays the entrance */
#home.loading .hole > * { display: none; }

/* The two ends of the route, faded into opposite corners of the screen behind everything */
.ends {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  /* Screened in grey, so only a picture's light parts show, as a paler blue */
  mix-blend-mode: screen;
}
#home .wrap { position: relative; }
.end-pic {
  /* Fades out on an easing curve from its corner and is fully gone by the picture's own edges,
     so no side of the picture ever shows */
  --fade: #000, rgba(0, 0, 0, .86) 22%, rgba(0, 0, 0, .55) 45%, rgba(0, 0, 0, .24) 66%, rgba(0, 0, 0, .06) 84%, transparent 96%;
  position: absolute;
  width: min(max(84vmin, 54vh), 760px);
  aspect-ratio: 1;
  background: center 30% / cover no-repeat;
  filter: grayscale(1) contrast(1.1) brightness(1.25);
  opacity: 0;
  transition: opacity 1.2s ease, transform 1.8s cubic-bezier(.2, .8, .2, 1);
}
.end-pic.from {
  top: 0;
  left: 0;
  transform: scale(1.06);
  transform-origin: 0 0;
  -webkit-mask-image: radial-gradient(farthest-side at 0 0, var(--fade));
  mask-image: radial-gradient(farthest-side at 0 0, var(--fade));
}
.end-pic.to {
  right: 0;
  bottom: 0;
  transform: scale(1.06);
  transform-origin: 100% 100%;
  transition-delay: .5s;
  -webkit-mask-image: radial-gradient(farthest-side at 100% 100%, var(--fade));
  mask-image: radial-gradient(farthest-side at 100% 100%, var(--fade));
}
/* A drawing on a transparent background (a logo, a map; see pictureKind in app.js) is shown whole, set in from
   its corner, and dark lines on it are flipped light */
.end-pic.drawing { box-sizing: border-box; padding: 7%; background-origin: content-box; background-size: contain; }
.end-pic.from.drawing { padding-right: 24%; background-position: 0 15%; }
.end-pic.to.drawing { padding-left: 24%; background-position: 100% 85%; }
.end-pic.dark { filter: invert(1) grayscale(1) contrast(1.1) brightness(1.25); }
.end-pic.in { opacity: .4; transform: none; }
#home.loading .ends { display: none; }

/* The menagerie (menagerie.js): pixel art in the blue beside the column on the home and result screens,
   above the corner pictures and below every sheet */
.menagerie { position: fixed; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; display: none; }
html[data-view="home"] .menagerie, html[data-view="end"] .menagerie { display: block; }
.menagerie canvas { position: absolute; top: 0; image-rendering: pixelated; pointer-events: auto; }
.menagerie .left { left: 0; }
.menagerie .right { right: 0; }
/* On a phone, strips at the top and foot of the column instead, tucked a little into the gaps around them */
.menagerie-strip { flex: none; align-self: center; image-rendering: pixelated; }
.menagerie-strip.top { margin-bottom: -16px; }
.menagerie-strip.bottom { margin-top: -12px; }

.note { background: var(--brand-deep); border-radius: 14px; padding: 14px 16px; font-weight: 600; line-height: 1.4; margin: 0; }

.cta { display: flex; flex-direction: column; gap: 12px; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 17px 28px;
  font-weight: 700;
  font-size: 1.125rem;
  cursor: pointer;
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-light { background: var(--on-brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--on-brand); box-shadow: inset 0 0 0 2px var(--on-brand-line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 2px var(--on-brand); }
.btn-brand { background: var(--brand); color: var(--on-brand); }
.rules { margin: 0; text-align: center; color: var(--on-brand-dim); font-size: .95rem; }
.foot { font-size: .75rem; color: var(--on-brand-dim); line-height: 1.5; }
.foot a { color: inherit; }
.text-btn {
  background: none;
  border: 0;
  padding: 8px 0;
  font-weight: 700;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
  cursor: pointer;
}

/* ---------- Result ---------- */
.result { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; }
.verdict {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(3.75rem, 19vw, 7.25rem);
  line-height: .95;
  margin: 0;
  letter-spacing: -.015em;
  text-wrap: balance;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.scoreline { margin: 12px 0 0; font-weight: 700; font-size: 1.125rem; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; }
.scoreline b { color: var(--on-brand); }
.subline { margin: 0; font-weight: 600; }
.grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.sq {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--on-brand-line);
  animation: pop .35s cubic-bezier(.3, 1.5, .5, 1) both;
  animation-delay: calc(.25s + var(--i) * 90ms);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}
.sq.up, .key.up, .dot.up { background: var(--up); }
.sq.same, .key.same, .dot.same { background: var(--same); }
.sq.down, .key.down, .dot.down { background: var(--down); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 10px 0 0; font-size: .8125rem; color: var(--on-brand-dim); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -4px; }

.copy-fallback {
  width: 100%;
  min-height: 140px;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  background: var(--brand-deep);
  color: var(--on-brand);
  font: 600 .95rem/1.5 var(--f-ui);
  resize: none;
}

.vs { background: var(--brand-deep); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.vs-line { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.875rem; line-height: 1.1; }

.routes { display: flex; flex-direction: column; gap: 6px; }
.route { list-style: none; margin: 0; padding: 0; }
.route li {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}
.route li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 10px;
  top: calc(50% + 9px);
  height: calc(100% - 18px);
  border-left: 2px solid var(--on-brand-line);
}
/* A route draws itself link by link the first time it scrolls into view */
.route:not(.seen) li { opacity: 0; }
.route.seen li { animation: fade .3s ease both; animation-delay: calc(min(var(--i), 12) * 90ms); }
.route.seen .dot { animation: pop .35s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: calc(min(var(--i), 12) * 90ms); }
.route.seen li:not(:last-child)::after { animation: trace .25s ease-out both; animation-delay: calc(min(var(--i), 12) * 90ms + 110ms); }
.route a { color: var(--on-brand); font-weight: 700; font-size: 1.05rem; text-decoration: none; overflow-wrap: anywhere; }
.route a:hover { text-decoration: underline; text-underline-offset: 3px; }
.dot { width: 14px; height: 14px; margin-left: 4px; border-radius: 50%; background: var(--on-brand); }
.dot.start { background: transparent; box-shadow: inset 0 0 0 3px var(--on-brand); }
.tag {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--on-brand-dim);
}
.fold summary {
  cursor: pointer;
  font-weight: 700;
  padding: 10px 0;
  color: var(--on-brand-dim);
  list-style: none;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "+ "; }
.fold[open] summary::before { content: "− "; }

/* ---------- Global board ---------- */
.rankline { margin: 2px 0 0; font-weight: 700; font-size: 1.125rem; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.rankline b { color: var(--on-brand); }
.played {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  font-weight: 700;
  font-size: .9375rem;
  color: var(--on-brand-dim);
  font-variant-numeric: tabular-nums;
  animation: fade .4s ease both;
}
.played::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  animation: live 2s ease-out infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.board { display: flex; flex-direction: column; gap: 14px; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 4px; border-bottom: 1px solid var(--on-brand-line); }
.board-head .label { margin: 0; padding: 0; border: 0; }
.board-sum { margin: 0; font-weight: 700; font-size: .9375rem; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; text-align: right; }
.board.loading .curve, .board.loading .lb { opacity: .4; transition: opacity .2s; }
.board-note { margin: 0; font-weight: 600; color: var(--on-brand-dim); }
.board-note .text-btn { color: var(--on-brand); margin-left: 6px; }

.curve { position: relative; touch-action: pan-y; }
.curve svg { display: block; overflow: visible; }
.cv-base { stroke: var(--on-brand-line); stroke-width: 1; }
.cv-area { fill: var(--on-brand); opacity: .12; animation: fade .6s ease .25s both; }
.cv-line {
  fill: none;
  stroke: var(--on-brand);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  animation: draw .9s cubic-bezier(.4, 0, .2, 1) both;
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.cv-x { fill: var(--on-brand-dim); font: 700 12px var(--f-ui); font-variant-numeric: tabular-nums; }
.cv-x.par { fill: var(--on-brand); font-weight: 800; }
.cv-rule { stroke: var(--on-brand-dim); stroke-width: 1.5; }
.cv-you { fill: var(--on-brand); stroke: var(--brand); stroke-width: 3; animation: pop .35s cubic-bezier(.3, 1.5, .5, 1) .7s both; transform-box: fill-box; transform-origin: center; }
.cv-you-t { fill: var(--on-brand); font: italic 400 16px var(--f-display); animation: fade .3s ease .8s both; }
.cv-dot { fill: var(--on-brand); stroke: var(--brand); stroke-width: 2; pointer-events: none; }
.cv-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .8125rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  font-variant-numeric: tabular-nums;
}

.lb { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lb th {
  padding: 0 10px 6px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--on-brand-dim);
  text-align: right;
}
.lb td { padding: 10px; border-top: 1px solid var(--on-brand-line); font-weight: 700; text-align: right; }
.lb .lb-rank { width: 3em; text-align: left; color: var(--on-brand-dim); }
.lb .lb-name { text-align: left; overflow-wrap: anywhere; }
.lb .lb-n { width: 4.5em; }
.lb tr.me td { background: var(--on-brand); color: var(--brand); border-top-color: transparent; }
.lb tr.me + tr td { border-top-color: transparent; }
.lb tr.me td:first-child { border-radius: 10px 0 0 10px; }
.lb tr.me td:last-child { border-radius: 0 10px 10px 0; }
.lb tr.lb-gap td { padding: 2px 10px; text-align: left; color: var(--on-brand-dim); }

/* A board still open somewhere refreshes itself: a live dot by the count, a flash on a new #1 */
.board.live .board-sum { display: inline-flex; align-items: center; gap: 8px; }
.board.live .board-sum::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  animation: live 2s ease-out infinite;
}
.lb tr.new-lead td { animation: lead-flash 1.8s ease-out; }
@keyframes lead-flash { 0%, 35% { background: rgba(255, 255, 255, .28); } }
.curve.quiet * { animation: none; }

/* Each run that took #1 */
.leads summary { padding-bottom: 6px; }
.lead-lb th:first-child { text-align: left; }
.lb .lead-at { width: 1%; white-space: nowrap; text-align: left; color: var(--on-brand-dim); }

.whoami p { margin: 0; color: var(--on-brand-dim); font-weight: 600; }
.whoami b { color: var(--on-brand); }
.whoami .text-btn { color: var(--on-brand); margin-left: 8px; }
.name-form { display: flex; gap: 8px; }
.name-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--brand-deep);
  color: var(--on-brand);
  font: 700 1rem var(--f-ui);
}
.btn-sm { padding: 12px 22px; font-size: 1rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.save-nudge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 10px 10px 16px;
  border-radius: 18px;
  background: var(--brand-deep);
}
.whoami .save-nudge p { color: var(--on-brand); font-weight: 700; line-height: 1.3; text-wrap: balance; }
.save-nudge .btn { flex: none; padding: 10px 20px; }

/* ---------- Account ---------- */
.topline .meta { margin-left: auto; }
.acct-btn {
  flex: none;
  align-self: center;
  height: 32px;
  min-width: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--on-brand-line);
  color: var(--on-brand);
  font-weight: 800;
  font-size: .875rem;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
.acct-btn:hover { box-shadow: inset 0 0 0 2px var(--on-brand); }
.acct-btn:active { transform: scale(.94); }
.acct-btn.in { width: 32px; padding: 0; background: var(--on-brand); color: var(--brand); box-shadow: none; font: 600 1.1875rem/1 var(--f-display); }

.acct-body { display: flex; flex-direction: column; gap: 12px; }
/* Google's button is a light-scheme iframe; matching its scheme keeps the browser from painting a white box behind it in dark mode */
.gsi { min-height: 44px; display: flex; justify-content: center; align-items: center; margin: 4px 0; color-scheme: light; }
.gsi .acct-fine { text-align: center; }
.acct-fine { margin: 0; font-size: .8125rem; line-height: 1.45; color: var(--muted); }
.acct-fine b { color: var(--ink); }
.acct-fine a { color: inherit; text-underline-offset: 3px; }
.acct-stats { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.sheet .acct-later, .sheet .acct-delete { align-self: center; color: var(--muted); }
.sheet .acct-delete { align-self: flex-start; padding: 4px 0; font-size: .8125rem; }
.dev-form { display: flex; gap: 8px; }
.dev-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--surface);
  color: var(--ink);
  font: 700 1rem var(--f-ui);
}
.sheet.busy .sheet-card { opacity: .6; pointer-events: none; transition: opacity .2s; }

/* ---------- Privacy page ---------- */
.legal { gap: 22px; }
.legal .wordmark { color: inherit; }
.legal h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(3rem, 15vw, 5rem); line-height: 1; margin: 12px 0 0; }
.legal .lede { margin: 0; font-weight: 700; font-size: 1.125rem; line-height: 1.45; }
.legal section { display: flex; flex-direction: column; gap: 8px; }
.legal section .label { margin: 0; }
.legal p, .legal li { margin: 0; line-height: 1.55; color: var(--on-brand-dim); }
.legal b { color: var(--on-brand); }
.legal ul { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.legal a { color: var(--on-brand); text-underline-offset: 3px; }
.legal .foot { margin-top: auto; font-size: .9375rem; font-weight: 700; }

.end-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; color: var(--on-brand-dim); }
.next { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.end-links { display: flex; flex-wrap: wrap; gap: 18px; }
.end-links .text-btn { color: var(--on-brand); }

/* ---------- Past dailies ---------- */
.cta .past-btn { align-self: center; padding: 2px 0; color: var(--on-brand); }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 6px 0;
  font-weight: 800;
  font-size: 1.0625rem;
  color: var(--on-brand);
  cursor: pointer;
}
.back-btn::before {
  content: "";
  width: 9px;
  height: 9px;
  border-left: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: rotate(45deg);
}
.back-btn:active { transform: scale(.96); }
.page-head { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.page-title, .day-pair {
  font-family: var(--f-display);
  font-weight: 400;
  line-height: 1.02;
  margin: 0;
  letter-spacing: -.01em;
  text-wrap: balance;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.page-title { font-size: clamp(3rem, 14vw, 5rem); }
.day-pair { font-size: clamp(2.4rem, 10vw, 3.75rem); overflow-wrap: anywhere; }
.day-arrow { color: var(--on-brand-dim); }
.page-sub { margin: 0; font-weight: 700; font-size: 1.125rem; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; }

.past-list { list-style: none; margin: 0 -10px; padding: 0; }
.past-list li { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(min(var(--i), 8) * 45ms); }
.past-list li + li .past-row::before {
  content: "";
  position: absolute;
  inset: 0 10px auto;
  border-top: 1px solid var(--on-brand-line);
}
.past-row {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 10px;
  background: none;
  border: 0;
  border-radius: 14px;
  text-align: left;
  color: var(--on-brand);
  cursor: pointer;
}
.past-row:hover { background: var(--brand-deep); }
.past-list li:hover .past-row::before, .past-list li:hover + li .past-row::before { border-color: transparent; }
.past-row:active { transform: scale(.985); }
.past-n { font-family: var(--f-display); font-weight: 400; font-size: 2rem; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.past-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.past-pair { font-weight: 800; font-size: 1.0625rem; line-height: 1.25; overflow-wrap: anywhere; }
.past-line { font-weight: 600; font-size: .875rem; line-height: 1.35; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; }
.past-you {
  min-width: 3.2rem;
  text-align: right;
  font-weight: 600;
  font-size: .8125rem;
  color: var(--on-brand-dim);
  white-space: nowrap;
}
.past-you b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 1.9rem; line-height: 1; font-variant-numeric: lining-nums; color: var(--on-brand); }

.day-you { display: flex; flex-direction: column; gap: 2px; }
.day-you .label { margin: 0; }
.day-score { margin: 6px 0 0; font-weight: 700; font-size: 1.125rem; color: var(--on-brand-dim); font-variant-numeric: tabular-nums; }
.day-score b { color: var(--on-brand); }
.day-you .grid { margin-top: 10px; }
.day-you .sq { width: 26px; height: 26px; border-radius: 7px; font-size: .875rem; animation-delay: calc(.1s + var(--i) * 50ms); }

/* ---------- Play ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.hud, .trail {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.hud { display: flex; align-items: center; gap: 10px; padding-block: 10px 8px; }
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s;
}
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.chip {
  flex: 1;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: var(--brand);
  color: var(--on-brand);
  cursor: pointer;
  text-align: left;
  transition: transform .12s ease;
}
.chip:active { transform: scale(.98); }
.chip svg { flex: none; }
.chip-t { min-width: 0; font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 40px; }
.stat-time { min-width: 50px; }
.num { font-family: var(--f-display); font-weight: 400; font-size: 1.75rem; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.lbl { font-size: .6875rem; font-weight: 600; color: var(--muted); }
/* A new click count rolls up into place */
.roll { animation: roll .3s cubic-bezier(.2, .8, .2, 1); }

.trail {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: 0 10px;
  font-size: .8125rem;
  color: var(--muted);
  white-space: nowrap;
}
.trail::-webkit-scrollbar { display: none; }
.crumb.now { color: var(--ink); font-weight: 700; }
.crumb.fresh, .sep:has(+ .crumb.fresh) { animation: crumb .35s cubic-bezier(.2, .8, .2, 1) both; }
.crumb.was-back::before { content: "↩ "; }
.sep { opacity: .45; }

.loadbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--link);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
}
.loading .loadbar { opacity: 1; animation: load 1.8s cubic-bezier(.1, .7, .2, 1) forwards; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding-block: 28px calc(80px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#art { transition: opacity .15s ease; }
#art.leaving { opacity: .35; }
#art.entering { animation: enter .32s cubic-bezier(.2, .8, .2, 1); }
#art.entering-back { animation: enter-back .32s cubic-bezier(.2, .8, .2, 1); }

/* A tapped link lifts off the page and grows into the title of the article it opens */
.flyer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9;
  padding: 0 2px;
  border-radius: 4px;
  background: var(--link);
  color: var(--paper);
  font-family: var(--f-read);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: 0 0;
}

/* Start: today's target shrinks into the chip that keeps it in view while you play */
#toTitle, #targetChip { view-transition-name: target; }
::view-transition-group(target) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
/* ---------- Overlays ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  animation: fade .2s ease;
}
.sheet-card {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sheet .3s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 700px) { .sheet { align-items: center; } }
.sheet .label { color: var(--muted); margin: 6px 0 0; }
.sheet h2 { font-family: var(--f-display); font-weight: 400; font-size: 2.25rem; line-height: 1.05; margin: 0; text-wrap: balance; }
.sheet .label { color: var(--muted); }
.sheet-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 14px; background: var(--surface); }
.sheet-desc { margin: 0; color: var(--muted); font-weight: 600; }
.sheet-extract { margin: 0; font-family: var(--f-read); line-height: 1.6; }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .text-btn { color: var(--muted); }

.wipe {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--brand);
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
  transition: clip-path .55s cubic-bezier(.7, 0, .2, 1);
}
.wipe.go { clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%)); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  max-width: calc(100% - 32px);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .95rem;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-16px); } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }
@keyframes roll { from { opacity: 0; transform: translateY(.5em); } }
@keyframes crumb { from { opacity: 0; transform: translateX(10px); } }
@keyframes trace { from { clip-path: inset(0 0 100% 0); } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { opacity: 0; transform: translateY(24px); } }
@keyframes load { from { transform: scaleX(.04); } to { transform: scaleX(.9); } }

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