/* Sarah's Struggles: the one stylesheet (docs/style-guide.md, Moth Nook; gh8-t1). Mobile first: one column, designed
   at 360 px, nothing sideways at 320 px. Tokens first, then the shared components, then one section per page task.
   Page tasks add rules only inside their own section at the end and never edit tokens or shared components. */

/* ---------- Tokens (guide 3 and 5): light here, night below ---------- */
:root {
  color-scheme: light dark;
  --bg: #d9efe6;
  --card: #fbf5e6;
  --text: #2a1a2e;
  --muted: #5c485e;
  --line: #dcb7bf;
  --line-strong: #7a5d6f;
  --outline: #2f4a3a;
  --accent: #5a2b62;
  --on-accent: #fbf5e6;
  --cookie-bg: #f5cfae;
  --cookie-ink: #5a2e14;
  --mischief: #9a1c66;
  --on-mischief: #fbf5e6;
  --kind: #2d6544;
  --danger: #a3241c;
  --notice-bg: #f7dde3;
  --focus: #005f73;
  --pop: #c48a98;
  --paper: #f7f1e3;
  --ink: #2a1a2e;
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --radius: 0.9rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-news: Georgia, "Times New Roman", serif;
  --tabbar-h: 3.5rem;
}

/* Night: the same room by candlelight. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1517;
    --card: #2b2023;
    --text: #f6ead2;
    --muted: #cdb9a6;
    --line: #4b3640;
    --line-strong: #a8919a;
    --outline: #d9b56a;
    --accent: #cfa6e6;
    --on-accent: #1c1517;
    --cookie-bg: #f5cfae;
    --cookie-ink: #5a2e14;
    --mischief: #f08cc0;
    --on-mischief: #1c1517;
    --kind: #9fd6a8;
    --danger: #ff9180;
    --notice-bg: #3a2630;
    --focus: #8fd3e8;
    --pop: #6a4a5a;
    --paper: #f7f1e3;
    --ink: #2a1a2e;
  }
}

/* ---------- Base, the wall, the night glow ---------- */
* { box-sizing: border-box; }

/* The hidden attribute wins over any display rule below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  /* The specimen-label frame (guide 5), resolved here where the scheme's tokens apply. */
  --label: 0 0 0 4px var(--card), 0 0 0 5.5px var(--line);
}

img { max-width: 100%; }

/* The sprite only holds symbols and patterns: out of sight, but not display:none (that can drop the patterns). */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* The wall (guide 4): a faint motif tile behind everything, one pattern per scheme. Decoration only. */
.wall { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.wall .wall-dark { display: none; }

@media (prefers-color-scheme: dark) {
  .wall .wall-light { display: none; }
  .wall .wall-dark { display: inline; }
  /* A soft candle glow in the corner. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(circle at 85% 4%, rgb(242 184 75 / 0.13), transparent 55%);
  }
}

/* ---------- Page header and column ---------- */
.appbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s2);
  max-width: 36rem;
  margin: 0 auto;
  padding: var(--s3) var(--s4) 0;
}

/* The app name: an italic serif luggage tag. */
.appname {
  font: italic 700 0.95rem/1.5 var(--font-head);
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--outline);
  border-radius: 0.35rem 999px 999px 0.35rem;
  padding: 0.05rem 0.8rem 0.05rem 0.6rem;
}

main {
  display: block;
  max-width: 36rem;
  margin: 0 auto;
  padding: var(--s4);
  overflow-wrap: anywhere;
}

/* Nothing hides behind the tab bar. */
body:has(> .tabbar) main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s5)); }

section { margin-bottom: var(--s5); }

/* ---------- Type (guide 5) ---------- */
h1 { font: 700 1.65rem/1.2 var(--font-head); margin: var(--s3) 0 var(--s4); }
h2 { font: 700 1.2rem/1.25 var(--font-head); margin: 0 0 var(--s2); }
h3 { font: 700 1.05rem/1.3 var(--font-head); margin: 0 0 var(--s2); }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); text-underline-offset: 2px; }

/* A back link above the page's h1 (struggle, week, front page): a 44 px target (guide 6). */
.back { margin-bottom: var(--s2); }
.back a { display: inline-flex; align-items: center; gap: var(--s1); min-height: 2.75rem; font-weight: 700; }
/* A link alone on its line (home's "See the whole week", a struggle's week link): a 44 px target too. */
.link-line a { display: inline-flex; align-items: center; min-height: 2.75rem; }

.muted { color: var(--muted); font-size: 0.875rem; }
.big { font: 700 1.2rem/1.3 var(--font-head); }
.prompt { font: 700 1.25rem/1.3 var(--font-head); margin-bottom: var(--s2); }
.good { color: var(--kind); font-weight: 700; }
.error { color: var(--danger); font-weight: 600; }
/* An error line takes no room until it speaks. */
.error:empty { margin: 0; }

/* Visually hidden, still read (the first-place "1"). */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Text never sits on the wall (guide 4): headings and lines straight in the page, outside any card, get a solid
   --bg backing. Zero specificity, so any page rule wins; .on-wall does the same for anything else. */
:where(main :is(h1, h2, h3, p, label, legend)):not(:where(.card, .notice, .front-page, .card *, .notice *,
  .front-page *, dialog *, button *, .btn *, .embed *)),
.on-wall {
  width: fit-content;
  max-width: 100%;
  background: var(--bg);
  box-shadow: 0 0 0 5px var(--bg);
  border-radius: 4px;
}
/* At night the halo's edge fades into the candle glow instead of ending in a hard dark box (gh8-t6 T6-3); the fill
   under the text stays solid --bg. */
@media (prefers-color-scheme: dark) {
  :where(main :is(h1, h2, h3, p, label, legend)):not(:where(.card, .notice, .front-page, .card *, .notice *,
    .front-page *, dialog *, button *, .btn *, .embed *)),
  .on-wall { box-shadow: 0 0 8px 6px var(--bg); }
}
:where(main :is(p, h2)):empty { box-shadow: none; }

/* ---------- Icons (motifs from the sprite, guide 4) ---------- */
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.eye { color: var(--mischief); }
.with-icon { display: flex; align-items: center; gap: var(--s2); }
.with-icon .icon { width: 1.5em; height: 1.5em; }

/* ---------- Cards: specimen labels (guide 5, 7) ---------- */
.card {
  position: relative;
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius);
  padding: var(--s4);
  margin: 6px 6px calc(var(--s4) + 6px);
  box-shadow: var(--label);
  animation: settle 200ms ease-out;
}
.card.flush { padding: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---------- Buttons: pills with a 2 px drop (guide 7) ---------- */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--s2) var(--s4);
  border: 1.5px solid var(--outline);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 2px 0 var(--outline);
  cursor: pointer;
}
:is(button, .btn).secondary { background: var(--card); color: var(--accent); }
:is(button, .btn).kind { background: var(--card); color: var(--kind); }
:is(button, .btn).mischief { background: var(--mischief); color: var(--on-mischief); }
:is(button, .btn).mischief .eye { color: inherit; }
:is(button, .btn) .icon { width: 1.2em; height: 1.2em; vertical-align: 0; }
:is(button, .btn):active:not(:disabled) { box-shadow: none; transform: translateY(2px); }
button:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; box-shadow: none; cursor: default; }
:is(button, .btn) + :is(button, .btn) { margin-top: var(--s2); }
.inline { width: auto; }

/* Several actions on one line. */
.actions,
.row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
:is(.actions, .row) > :is(button, .btn) { width: auto; flex: 1 1 auto; margin-top: 0; }

.stack { display: grid; gap: var(--s3); }

/* ---------- Chips: luggage tags (guide 5, 7) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0 var(--s2);
  padding: 0 0.65rem 0 0.45rem;
  border: 1.5px solid currentColor;
  border-radius: 0.3rem 999px 999px 0.3rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.5;
}
.chip.mischief { color: var(--mischief); }
.chip.kind { color: var(--kind); }
.chip.you { color: var(--accent); }
/* A row of chips (an answer card's tags, an admin player's tags). */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips .chip { margin: 0; }

/* ---------- Cookie badge (guide 7) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.65rem 0.05rem 0.35rem;
  border: 1.5px solid var(--outline);
  border-radius: 999px;
  background: var(--cookie-bg);
  color: var(--cookie-ink);
  box-shadow: 0 2px 0 var(--outline);
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
}
.badge .icon { width: 1.3em; height: 1.3em; vertical-align: 0; }
.badge.hop { animation: hop 300ms ease-out; }

/* ---------- Notices and the toast (guide 7) ---------- */
.notice {
  background: var(--notice-bg);
  color: var(--text);
  border: 1.5px solid var(--outline);
  border-left: 7px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s4);
}
.notice.ok,
.notice.kind-edge { border-left-color: var(--kind); }
.notice.err { border-left-color: var(--danger); }
.notice.mischief-edge { border-left-color: var(--mischief); }
.card.notice { margin: 6px 6px calc(var(--s4) + 6px); }
.notice p { margin: 0 0 var(--s2); }
.notice p:last-child { margin-bottom: 0; }
.notice p:has(> .icon) { display: flex; align-items: center; gap: var(--s2); }
.notice .icon { width: 1.5em; height: 1.5em; }
/* Links on rose glass stay in the text colour (a pair the guide lists), bold and underlined. */
.notice a { color: var(--text); font-weight: 700; }

.toast {
  position: fixed;
  left: var(--s4);
  right: var(--s4);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s3));
  z-index: 20;
  max-width: 34rem;
  margin: 0 auto;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}

/* ---------- Forms (guide 7) ---------- */
label { display: block; font-weight: 700; margin-bottom: var(--s1); }

input,
select,
textarea { font: inherit; color: var(--text); }

:is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  margin-bottom: var(--s3);
  padding: var(--s2) var(--s3);
  border: 1.5px solid var(--line-strong);
  border-radius: 0.6rem;
  background: var(--card);
}
textarea { min-height: 7.5rem; border-radius: var(--radius); resize: vertical; }
[aria-invalid="true"] { border-color: var(--danger); }
input[type="file"]::file-selector-button {
  margin-right: var(--s3);
  padding: var(--s1) var(--s3);
  border: 1.5px solid var(--outline);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-weight: 700;
}

input[type="checkbox"],
input[type="radio"] { width: 1.5rem; height: 1.5rem; margin: 0; flex: none; accent-color: var(--accent); }

/* The live count under an answer ("212 / 500"). */
.count { display: flex; justify-content: space-between; gap: var(--s3); margin: 0 0 var(--s3); }

/* A checkbox row: 44 px tall, the whole row taps. */
.check {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 2.75rem;
  margin-bottom: var(--s3);
  font-weight: 600;
  cursor: pointer;
}

/* Radio rows (the mischief kinds). */
.choices { border: 0; margin: 0 0 var(--s3); padding: 0; min-width: 0; }
.choices legend { padding: 0; margin-bottom: var(--s1); font-weight: 700; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  min-height: 2.75rem;
  padding: var(--s2) 0;
  border-bottom: 1.5px dotted var(--line-strong);
  font-weight: 400;
  cursor: pointer;
}
.choice input { margin-top: 0.1rem; accent-color: var(--mischief); }

/* ---------- Lists, standings, ledger (guide 7) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li:not(.card) { margin: 0 0 var(--s3); }
.list p { margin-bottom: var(--s2); }

.standings { list-style: none; margin: 0; padding: 0; }
.standings li {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 3.5rem;
  padding: var(--s2) var(--s3);
  border-bottom: 1.5px dotted var(--line-strong);
}
.standings li:last-child { border-bottom: 0; }
.standings li.me { background: var(--notice-bg); }
.rank { width: 1.6rem; flex: none; font: 700 1.05rem/1.2 var(--font-head); text-align: center; color: var(--muted); }
.rank .top { width: 1.4rem; height: 1.4rem; vertical-align: middle; color: var(--accent); }
.who { flex: 1; min-width: 0; font-weight: 600; }
.standings .net { display: block; font-weight: 400; }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1.5px solid var(--outline);
  border-radius: 50%;
  background: var(--cookie-bg);
  color: var(--cookie-ink);
  font-size: 0.875rem;
  font-weight: 800;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
/* A cursed avatar wears the dashed ring everywhere. */
.avatar.cursed { outline: 2.5px dashed var(--mischief); outline-offset: 3px; transform: rotate(-6deg); }

.ledger { list-style: none; margin: 0 0 var(--s4); padding: 0; font-size: 0.95rem; }
.ledger li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; }
.plus { color: var(--kind); font-weight: 800; }
.minus { color: var(--muted); font-weight: 800; }

/* ---------- Empty state (guide 7, G-11) ---------- */
.empty { text-align: center; padding-top: var(--s5); }
.empty .icon { width: 64px; height: 64px; vertical-align: bottom; }
.empty .e-mush { color: var(--mischief); }
.empty .e-snail { width: 48px; height: 48px; margin-left: -10px; color: var(--kind); }
.empty .e-paper { width: 48px; height: 48px; color: var(--accent); }
.empty-line { font: 700 1.1rem/1.35 var(--font-head); }
.empty.small { padding-top: var(--s3); }

/* ---------- Tab bar (guide 6) ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1.5px solid var(--outline);
}
.tabbar a {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-width: 0;
  max-width: 7.5rem;
  min-height: var(--tabbar-h);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.tabbar a .icon { width: 1.5rem; height: 1.5rem; vertical-align: 0; }
/* At 200 % text a label clips with an ellipsis instead of running into its neighbour. */
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 800; }
.tabbar a[aria-current="page"] span { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.tabbar a:focus-visible { outline-offset: -3px; }
/* Five tabs fit at 320 px. */
@media (max-width: 22.49rem) {
  .tabbar a { font-size: 0.8125rem; }
}

/* ---------- Mischief moments (guide 9) ---------- */
/* The serenade delivery: a big mischief pill. */
.delivery {
  flex-direction: column;
  gap: var(--s1);
  min-height: 4.75rem;
  margin: 0 0 var(--s2);
  padding: var(--s3) var(--s4);
  /* A pill at its normal height; at 200 % text a rounded card rather than a circle. */
  border-radius: 2.5rem;
  background: var(--mischief);
  color: var(--on-mischief);
  font-size: 1.15rem;
}
.delivery .eye { color: inherit; }
.delivery .icon { width: 2rem; height: 2rem; animation: blink 300ms ease-in-out 2; }
.delivery small { font-size: 0.875rem; font-weight: 500; }
.embed { position: relative; width: 100%; aspect-ratio: 16 / 9; margin-bottom: var(--s3); }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0.6rem; }

/* "You've been mothed": the cursed selfie pop-up. */
dialog.curse {
  width: calc(100% - 2rem);
  max-width: 22rem;
  padding: var(--s5) var(--s4) var(--s4);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  text-align: center;
  box-shadow: var(--label);
  animation: pop 250ms ease-out;
}
dialog.curse::backdrop { background: rgb(28 21 23 / 0.6); }
dialog.curse h2 { font-size: 1.35rem; margin: 0 0 var(--s2); }
.curse-frame { position: relative; width: 12rem; height: 12rem; margin: var(--s4) auto var(--s5); }
.curse-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 2px solid var(--outline);
  border-radius: 50%;
  outline: 3px dashed var(--mischief);
  outline-offset: 6px;
  background: var(--cookie-bg);
  transform: rotate(-4deg);
}
.curse-frame .moth { position: absolute; z-index: 1; width: 2.5rem; height: 2.5rem; color: var(--accent); animation: flutter 300ms ease-in-out 3; }
.curse-frame .moth:nth-of-type(1) { top: -1rem; left: -1rem; rotate: -20deg; }
.curse-frame .moth:nth-of-type(2) { top: 1.5rem; right: -1.5rem; width: 2rem; height: 2rem; rotate: 18deg; }
.curse-frame .moth:nth-of-type(3) { bottom: -1rem; left: 0.5rem; width: 1.75rem; height: 1.75rem; rotate: 8deg; }

/* Chomp: round bites out of the answer card's top-right corner. Display only: the text is kept on the server. */
.chomped { overflow: hidden; }
.chomped::before,
.chomped::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 2.5px var(--mischief);
  pointer-events: none;
  animation: chomp 300ms ease-out;
}
.chomped::before { top: -25px; right: 32px; }
.chomped::after { top: -19px; right: -7px; }
/* A cookie mended it: the bites shrink away. */
.chomped.mended::before,
.chomped.mended::after { animation: unchomp 300ms ease-in forwards; }
/* A bitten letter. */
.bite {
  display: inline-block;
  width: 0.55em;
  height: 0.8em;
  vertical-align: -0.05em;
  border-radius: 50%;
  background: radial-gradient(circle at 85% 15%, transparent 0 45%, var(--mischief) 47%);
}

/* The selfie pool. */
.selfies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(8rem, 100%), 1fr));
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.selfies li { display: flex; flex-direction: column; gap: var(--s2); }
.selfies li.card { margin: 6px; padding: var(--s3); }
.selfies img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 0.6rem; background: var(--cookie-bg); }
.selfies p { margin: 0; }

/* ---------- The Caper front page (guide 9): bone newsprint in both schemes ---------- */
.front-page {
  margin: 6px 6px var(--s5);
  padding: var(--s4);
  border: 1.5px solid var(--outline);
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--label);
  font-family: var(--font-news);
  transform: rotate(-0.5deg);
}
.front-page :is(h1, h2, h3) { font-family: var(--font-news); }
.front-page .masthead {
  position: relative;
  margin-bottom: var(--s3);
  padding: var(--s2) 2.25rem;
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
  text-align: center;
}
.front-page .masthead p { margin: 0; }
.front-page .masthead-name { font-size: 1.4rem; font-weight: 700; font-variant: small-caps; letter-spacing: 0.04em; line-height: 1.1; }
.front-page .masthead-line { font-family: var(--font); font-size: 0.875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.front-page .mast { position: absolute; top: 0.75rem; width: 1.65rem; height: 1.65rem; color: var(--ink); }
.front-page .mast.l { left: 0.15rem; rotate: -14deg; }
.front-page .mast.r { right: 0.15rem; rotate: 14deg; }
.front-page .headline { font: 700 2rem/1.1 var(--font-news); margin: 0 0 var(--s2); }
.front-page .byline { font-size: 0.875rem; font-style: italic; margin-bottom: var(--s3); }
.front-page .kicker { margin: 0 0 var(--s1); font-family: var(--font); font-size: 0.875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.front-page .prompt { font: italic 1rem/1.5 var(--font-news); margin-bottom: var(--s2); }
.front-page .story { margin: 0; padding: 0; list-style: none; }
.front-page .chapter { padding: var(--s2) 0; }
.front-page .story-text { margin: 0; line-height: 1.5; }
.front-page .chapter:first-child .story-text::first-letter {
  float: left;
  padding: 0.2rem 0.4rem 0 0;
  font-size: 3.1rem;
  font-weight: 700;
  line-height: 0.85;
}
.headline-line { font-family: var(--font-news); font-size: 1.1rem; }

/* ---------- Focus (guide 11) ---------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- Motion (guide 10): 150-300 ms, transform and opacity only, nothing loops ---------- */
@keyframes settle { from { transform: scale(0.97); } to { transform: none; } }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-4px) scale(1.06); } }
@keyframes blink { 0%, 100% { transform: none; } 50% { transform: scaleY(0.1); } }
@keyframes flutter { 50% { translate: 0 -5px; scale: 1.06 0.9; } }
@keyframes pop { from { opacity: 0; transform: scale(0.88) rotate(-3deg); } to { opacity: 1; transform: none; } }
@keyframes chomp { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes unchomp { to { opacity: 0; transform: scale(0); } }

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

/* ---------- Page task sections (G-4). Each task adds rules only between its own two markers. ---------- */
/* Keep the separator lines between sections: they keep the four tasks' additions apart, so they merge cleanly. */

/* == gh8-t2: home, invite, selfies == */
/* Home: the serenade pill puts the eye beside its line, the tap hint below (guide 9, the preview). */
.delivery .dl { display: flex; align-items: center; justify-content: center; gap: var(--s2); }
/* A struggle card or the opened serenade ends with its one action. */
:is(.list > li.card, .serenade) > .btn { margin-top: var(--s1); }
/* Selfies and Admin, linked from Home (guide 6). */
.links { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
/* The mothed pop-up with no selfie to show: an empty peach specimen in the same dashed ring. */
.curse-frame:has(> img[hidden])::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--outline);
  border-radius: 50%;
  outline: 3px dashed var(--mischief);
  outline-offset: 6px;
  background: var(--cookie-bg);
  transform: rotate(-4deg);
}
/* Invite: one welcome card, no tab bar (G-3). */
.welcome { margin-top: var(--s5); }
.welcome h1 { margin-top: 0; }
/* Selfies: your avatar beside its line; a big avatar keeps the shared ring (and the dashed one while cursed). */
.you { display: flex; align-items: center; gap: var(--s4); }
.you p { margin: 0; }
.avatar.lg { width: 4.5rem; height: 4.5rem; font-size: 1.25rem; }
/* Pool cards: the name, the date, then Delete at the foot of the card. */
.selfies .owner { font-weight: 700; }
.selfies li > button { margin-top: auto; }
/* == /gh8-t2 == */
/* ------------------------------------------------------------------------------------------------------ */
/* (separator: leave unchanged)                                                                           */
/* ------------------------------------------------------------------------------------------------------ */
/* == gh8-t3: struggle, week == */
/* The struggle card (guide 7): the tag chip on its own line, the caper's title, the prompt, the status line. */
:is(.struggle-card, .week-card) > .chip { margin-bottom: var(--s3); }
.caper-line { margin-bottom: var(--s1); color: var(--muted); font: italic 700 1rem/1.35 var(--font-head); }

/* The answer form: count on the right, the error line takes no room while empty. */
#answer-form .count { flex-wrap: wrap; }
#answer-form .count > :first-child { flex: 1 1 10rem; }
#answer-form .count > :last-child { margin-left: auto; text-align: right; white-space: nowrap; }
#answer-form .count .over { color: var(--danger); font-weight: 700; }
#answer-form .check .muted { font-weight: 400; }

/* Answer cards: a row of chips (shared .chips), the answer, notes, then Vote and Accuse sharing one line. */
/* The winner's tag: the one filled chip (--on-accent on --accent, a guide pair). */
.chip.win { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
/* Keep the first line clear of the chomp bites in the top-right corner. */
.answer.chomped > :first-child { padding-right: 4.5rem; }
.row.answer-actions { margin: var(--s3) 0 0; }
.row.answer-actions > * { flex: 1 1 7rem; }
.row.answer-actions > .accuse { display: flex; }
.row.answer-actions > .accuse:has(> p) { flex-basis: 100%; }
.row.answer-actions > .accuse > p { margin: 0; }

/* The week: the caper's title under its chip; quoted answers. */
.week-card .prompt { margin-bottom: var(--s3); }
.answer-quote { padding-left: var(--s3); border-left: 3px solid var(--line); }
/* == /gh8-t3 == */
/* ------------------------------------------------------------------------------------------------------ */
/* (separator: leave unchanged)                                                                           */
/* ------------------------------------------------------------------------------------------------------ */
/* == gh8-t4: standings, missions, mischief == */
/* /standings: the ledger rows in their card, dotted apart, newest first. */
#standings-card { overflow: hidden; } /* your row's fill keeps to the card's round corners */
.standings .badge { flex: none; }
#ledger li { align-items: center; padding: var(--s2) 0; }
#ledger li + li { border-top: 1.5px dotted var(--line-strong); }
#ledger .what { min-width: 0; }
#ledger .when { display: block; }
#ledger :is(.plus, .minus) { flex: none; font-size: 1.05rem; }

/* /missions: the mission flag dotted off inside the card; the status line under it. */
#mission .flag { margin: 0 0 var(--s3); padding-top: var(--s3); border-top: 1.5px dotted var(--line-strong); }
#mission .flag p { margin-bottom: var(--s1); }
#mission-status { font-weight: 600; }

/* /mischief: result notices in their live regions (empty, they take no space), the guess form dotted off inside a
   received card, the choice text beside its radio. */
.say .notice { margin-top: var(--s3); }
.card > .say .notice { margin-bottom: 0; }
.choice > span { flex: 1; min-width: 0; }
.guess { margin-top: var(--s3); padding-top: var(--s3); border-top: 1.5px dotted var(--line-strong); }
/* == /gh8-t4 == */
/* ------------------------------------------------------------------------------------------------------ */
/* (separator: leave unchanged)                                                                           */
/* ------------------------------------------------------------------------------------------------------ */
/* == gh8-t5: archive, front page, admin == */
/* Archive (/archive): one card per front page; the title link covers the card, so the whole card is one target. */
.papers h2 { margin: 0 0 var(--s1); }
.papers h2 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.papers h2 a:focus-visible { outline: none; }
.papers h2 a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 3px; }
.papers .headline-line { margin-bottom: var(--s2); }
/* A missing headline or chapter, said kindly, set apart by italics (ink on paper is the sheet's only pair). */
:is(.papers, .front-page) .missing { font-style: italic; }

/* The Caper front page (/archive/{id}), on the shared .front-page sheet (guide 9). */
/* The half-degree tilt of a long sheet never pushes the page sideways (nothing sideways at 320 px). */
main:has(> .front-page) { overflow-x: clip; }
/* A thin newsprint rule between chapters. */
.front-page .chapter + .chapter { border-top: 1px solid var(--ink); }

/* Admin (/admin): guide 7 cards and forms. */
#admin input[type="date"] { min-width: 0; }
/* Caper week status chips: the word says it, the colour only follows (--accent, --kind on --card). */
.chip.ad-running { color: var(--accent); }
.chip.ad-done { color: var(--kind); }
/* == /gh8-t5 == */
