/* ==========================================================================
   Tokens. Every colour, size, radius, shadow and duration the site uses.
   Components read these and nothing else (DESIGN.md).

   Light and dark: each colour is light-dark(light, dark) and the page follows
   the system setting. The light values are the brief's palette; the dark ones
   keep the same hues on a deep plum page.
   ========================================================================== */
:root {
  color-scheme: light dark;

  /* Text and paper */
  --ink: light-dark(#1C1A2B, #F2EFF7);
  --ink-soft: light-dark(#4A4659, #CBC6D6);
  --ink-muted: light-dark(#5F5A70, #A8A2B8);
  --ink-faint: light-dark(#A9A2B9, #6E6882);      /* decorative numbers, locked seals */
  --page: light-dark(#FAFAF8, #15131C);
  --paper: light-dark(#FFFFFF, #211E2B);          /* cards */
  --sand: light-dark(#F1EFEA, #2B2737);           /* secondary buttons, hover, inactive pills */
  --sand-deep: light-dark(#E6E2DA, #3A3548);
  --line: light-dark(#E4E1DA, #363145);           /* rare borders, empty bubbles */

  /* Solid: small dark controls (primary button, pills, stickers, pressed tabs).
     They turn light in dark mode so they still stand off the page. */
  --solid: light-dark(#1C1A2B, #F2EFF7);
  --on-solid: light-dark(#FFFFFF, #1C1A2B);
  --solid-accent: light-dark(#FBB27C, #A3480F);   /* peach text on a solid */
  /* Night: the big dark panels (Today's pick, streak, footer). Darker than the page in dark mode. */
  --night: light-dark(#1C1A2B, #0E0C14);
  --night-edge: light-dark(transparent, #2E2A3B);
  --on-night: light-dark(#FFFFFF, #F2EFF7);
  --on-night-soft: light-dark(#CFCAD9, #B4AEC3);
  --on-night-faint: light-dark(#A9A2B9, #8A849C);
  --on-night-hover: rgb(255 255 255 / .1);
  --on-ink: #FFFFFF;                               /* text on a strong colour fill (marks, destructive) */

  /* Brand */
  --peach: #FBB27C;                                /* highlighter, logo, active bubble */
  --peach-hover: #FCA466;
  --peach-deep: #E8803D;                           /* decorative only: bubble outlines, days max */
  --on-peach: #1C1A2B;                             /* text on peach, in both themes */
  --on-peach-soft: #4A3B33;
  --peach-ink: light-dark(#9A4A14, #FBB27C);       /* peach text on the page */
  --peach-band: light-dark(#FEF3EA, #251B1C);      /* hero band */
  --success: light-dark(#23704A, #74D6A0);
  --success-mark: light-dark(#3FA06C, #45B077);
  --success-tint: light-dark(#E6F6EC, #17301F);
  --danger: light-dark(#C2455A, #F48A9A);
  --danger-mark: light-dark(#D9566A, #E0667A);
  --danger-tint: light-dark(#FDECEE, #351820);
  --destructive: #B3364B;                          /* destructive button fill, white text on it */
  --destructive-ink: light-dark(#B3364B, #F48A9A); /* destructive text on page, paper or sand */
  --field-line: light-dark(#8D889A, #6E6882);      /* text-field edge: 3:1 on paper and page */
  --focus: light-dark(#C4621F, #FBB27C);           /* 3:1 on page and paper in both themes */
  --header-bg: light-dark(rgb(250 250 248 / .86), rgb(21 19 28 / .86));
  --scrim: light-dark(rgb(28 26 43 / .45), rgb(0 0 0 / .62));

  /* Answer letters A–D */
  /* The lines are the area bars, so a letter and its area can't drift apart */
  --letter-a: light-dark(#FCD9BD, oklch(40% .08 55));  --letter-a-ink: light-dark(#8E4512, oklch(90% .06 60));  --letter-a-line: var(--life-bar);
  --letter-b: light-dark(#DCD4F8, oklch(38% .09 290)); --letter-b-ink: light-dark(#4B3A99, oklch(88% .06 290)); --letter-b-line: var(--mind-bar);
  --letter-c: light-dark(#CDEEDB, oklch(38% .07 155)); --letter-c-ink: light-dark(#23704A, oklch(88% .07 155)); --letter-c-line: var(--world-bar);
  --letter-d: light-dark(#F8E7A6, oklch(42% .07 90));  --letter-d-ink: light-dark(#6E5106, oklch(90% .08 92));  --letter-d-line: var(--how-bar);

  /* Areas: bg (tile), blob (fill), ink (text on bg), bar (meters, rules), page (tint) */
  --mind-bg: light-dark(#EEEAFB, oklch(29% .05 290));  --mind-blob: light-dark(#C9BDF5, oklch(44% .1 290));  --mind-ink: light-dark(#4B3A99, oklch(86% .07 290));  --mind-bar: light-dark(#7E6BD6, oklch(70% .13 290));  --mind-page: light-dark(#F6F4FD, oklch(19% .02 290));
  --life-bg: light-dark(#FDEBDD, oklch(29% .045 55));  --life-blob: light-dark(#FBC59A, oklch(46% .09 55));  --life-ink: light-dark(#8E4512, oklch(86% .07 60));  --life-bar: light-dark(#E8803D, oklch(72% .13 55));  --life-page: light-dark(#FEF6EF, oklch(19% .018 55));
  --work-bg: light-dark(#E3F0FA, oklch(29% .045 245)); --work-blob: light-dark(#A9D2F2, oklch(45% .08 245)); --work-ink: light-dark(#1F5A86, oklch(86% .06 240)); --work-bar: light-dark(#3B86C4, oklch(70% .11 245)); --work-page: light-dark(#F2F7FC, oklch(19% .02 245));
  --world-bg: light-dark(#E2F4EA, oklch(29% .045 155)); --world-blob: light-dark(#A8DFBF, oklch(45% .08 155)); --world-ink: light-dark(#23704A, oklch(86% .07 155)); --world-bar: light-dark(#3FA06C, oklch(70% .12 155)); --world-page: light-dark(#F2F9F5, oklch(19% .018 155));
  --how-bg: light-dark(#FBF2D5, oklch(30% .045 90));   --how-blob: light-dark(#F4D772, oklch(48% .09 90));   --how-ink: light-dark(#6E5106, oklch(88% .09 92));   --how-bar: light-dark(#C99A12, oklch(76% .13 90));   --how-page: light-dark(#FDF9EC, oklch(19% .018 90));
  --home-bg: light-dark(#FCE6E8, oklch(29% .05 12));   --home-blob: light-dark(#F6B3BB, oklch(45% .1 12));   --home-ink: light-dark(#9A2E3E, oklch(86% .07 12));   --home-bar: light-dark(#D9566A, oklch(70% .14 12));   --home-page: light-dark(#FDF4F5, oklch(19% .02 12));

  /* Days grid (5 levels) */
  --days-0: var(--sand-deep);
  --days-1: light-dark(#FCDCC2, oklch(38% .06 55));
  --days-2: light-dark(#FBC59A, oklch(50% .09 55));
  --days-3: light-dark(#F5A066, oklch(62% .12 55));
  --days-4: light-dark(#E8803D, oklch(75% .14 55));

  /* Type: Valley Sans for everything; hierarchy from size and weight */
  --font-display: "Valley Sans", "Valley Sans Fallback", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Valley Sans", "Valley Sans Fallback", ui-sans-serif, system-ui, sans-serif;
  --fs-hero: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);
  --fs-page: clamp(2.25rem, 1.6rem + 2.8vw, 3.5rem);
  --fs-h2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-question: clamp(1.375rem, 1.1rem + 1.2vw, 2rem);
  --fs-score: clamp(3rem, 2.2rem + 3vw, 4.5rem);
  --fs-stat: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --fs-h2-sm: clamp(1.375rem, 1.2rem + .8vw, 1.75rem);  /* display titles in cards: mode cards, streak, fact of the day */
  --fs-h3: 1.1875rem;
  --fs-h4: 1.0625rem;
  --fs-lead: clamp(1.0625rem, 1rem + .25vw, 1.1875rem);
  --fs-body: 1rem;
  --fs-label: .9375rem;                            /* subject names in lists, small options, fact text in cards */
  --fs-small: .875rem;
  --fs-xs: .8125rem;
  --fs-tag: .75rem;
  --lh-tight: 1.06;                                /* h1: room for the tilted highlighter when it wraps */
  --lh-head: 1.12;
  --lh-snug: 1.25;                                 /* h3, h4, card titles, answers */
  --lh-body: 1.5;
  --track-display: -.03em;
  --track-head: -.02em;
  --track-snug: -.01em;
  --track-tag: .08em;

  /* Space: 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64 72 80 96 px */
  --s-1: .25rem;  --s-2: .375rem; --s-3: .5rem;   --s-4: .625rem; --s-5: .75rem;  --s-6: .875rem;
  --s-7: 1rem;    --s-8: 1.25rem; --s-9: 1.5rem;  --s-10: 1.75rem; --s-11: 2rem;  --s-12: 2.5rem;
  --s-13: 3rem;   --s-14: 3.5rem; --s-15: 4rem;   --s-16: 4.5rem; --s-17: 5rem;   --s-18: 6rem;
  --section-gap: clamp(4rem, 2.5rem + 5vw, 7.5rem);
  --gutter: clamp(1rem, 4vw, 3rem);
  --content-max: 75rem;
  --quiz-max: 53.75rem;
  --measure: 62ch;
  --tap: 2.75rem;
  --header-h: 4.25rem;
  /* Card padding: one fluid value so every card breathes the same at each width */
  --pad: clamp(var(--s-8), 1rem + 1.5vw, var(--s-9));
  --pad-lg: clamp(var(--s-8), .75rem + 3vw, var(--s-12));
  --pad-xl: clamp(var(--s-8), 5vw, var(--s-14));    /* the quiz card only */

  /* Shape: soft and chunky. The squircle is the signature: logo, letter
     tiles, answer badges, medals, the score. */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 34px;
  --r-pill: 999px;
  --r-note: 8px 8px 22px 8px;
  --squircle: 50% 50% 50% 22%;

  /* Depth: warm shadows in light, plain black in dark; chunky lips on pressable things */
  --shade: light-dark(rgb(70 45 20 / .06), rgb(0 0 0 / .35));
  --shade-deep: light-dark(rgb(70 45 20 / .28), rgb(0 0 0 / .6));
  --shadow-1: 0 1px 2px var(--shade);
  --shadow-2: 0 1px 2px var(--shade), 0 16px 32px -14px var(--shade-deep);
  --shadow-ink: 0 14px 28px -14px light-dark(rgb(28 26 43 / .5), rgb(0 0 0 / .7));
  --lip: 4px;
  --lip-up: 6px;                                   /* hover lift, and the resting lip on the score and the winner */
  --lip-down: 1px;                                 /* pressed */
  --lip-black: #000;                               /* under a dark control that stays dark in both themes */
  --lip-ink: light-dark(var(--lip-black), #8E889E);
  --lip-paper: light-dark(#E4DDD0, #0D0B12);
  /* Gloss: the light source on printed-sticker fills. Tiles in dark mode take
     a shade instead, so the light icon keeps its contrast. */
  --gloss: #FFFFFF;
  --gloss-tile: light-dark(#FFFFFF, #15131C);

  /* Stationery */
  --tape: light-dark(rgb(251 178 124 / .8), rgb(251 178 124 / .6));
  --pen-red: light-dark(#D9566A, #EE7486);
  --butter: light-dark(#FFF4C7, oklch(31% .05 92));
  --clip: light-dark(#8D889A, #B4AEC3);            /* paper-clip wire */
  --sheet: light-dark(#FFFFFF, #2A2636);           /* loose sheets under a card */
  --sheet-edge: var(--line);
  /* Two loose sheets showing under a card's bottom-right edge */
  --sheets: 5px 6px 0 -1px var(--sheet), 5px 6px 0 0 var(--sheet-edge), 10px 12px 0 -1px var(--sheet), 10px 12px 0 0 var(--sheet-edge);

  /* Motion */
  --dur-fast: 150ms;
  --dur: 180ms;
  --dur-slow: 300ms;
  --dur-mark: 260ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --ease-pop: cubic-bezier(.3, 1.6, .5, 1);

  /* Rules */
  --rule: 2px;
  --focus-ring: 3px solid var(--focus);
}

/* Area theming: any element with data-area exposes --a-* for its subtree */
[data-area="mind"]  { --a-bg: var(--mind-bg);  --a-blob: var(--mind-blob);  --a-ink: var(--mind-ink);  --a-bar: var(--mind-bar);  --a-page: var(--mind-page); }
[data-area="life"]  { --a-bg: var(--life-bg);  --a-blob: var(--life-blob);  --a-ink: var(--life-ink);  --a-bar: var(--life-bar);  --a-page: var(--life-page); }
[data-area="work"]  { --a-bg: var(--work-bg);  --a-blob: var(--work-blob);  --a-ink: var(--work-ink);  --a-bar: var(--work-bar);  --a-page: var(--work-page); }
[data-area="world"] { --a-bg: var(--world-bg); --a-blob: var(--world-blob); --a-ink: var(--world-ink); --a-bar: var(--world-bar); --a-page: var(--world-page); }
[data-area="how"]   { --a-bg: var(--how-bg);   --a-blob: var(--how-blob);   --a-ink: var(--how-ink);   --a-bar: var(--how-bar);   --a-page: var(--how-page); }
[data-area="home"]  { --a-bg: var(--home-bg);  --a-blob: var(--home-blob);  --a-ink: var(--home-ink);  --a-bar: var(--home-bar);  --a-page: var(--home-page); }
/* Neutral fallback (mixed rounds, no subject) */
:root, [data-area="mixed"] { --a-bg: var(--sand); --a-blob: light-dark(var(--peach), oklch(46% .09 55)); --a-ink: var(--peach-ink); --a-bar: var(--peach-deep); --a-page: var(--page); }

@supports not (color: light-dark(#000, #fff)) {
/* ==========================================================================
   Tokens. Every colour, size, radius, shadow and duration the site uses.
   Components read these and nothing else (DESIGN.md).

   Light and dark: each colour is light and the page follows
   the system setting. The light values are the brief's palette; the dark ones
   keep the same hues on a deep plum page.
   ========================================================================== */
:root {
  color-scheme: light;

  /* Text and paper */
  --ink: #1C1A2B;
  --ink-soft: #4A4659;
  --ink-muted: #5F5A70;
  --ink-faint: #A9A2B9;      /* decorative numbers, locked seals */
  --page: #FAFAF8;
  --paper: #FFFFFF;          /* cards */
  --sand: #F1EFEA;           /* secondary buttons, hover, inactive pills */
  --sand-deep: #E6E2DA;
  --line: #E4E1DA;           /* rare borders, empty bubbles */

  /* Solid: small dark controls (primary button, pills, stickers, pressed tabs).
     They turn light in dark mode so they still stand off the page. */
  --solid: #1C1A2B;
  --on-solid: #FFFFFF;
  --solid-accent: #FBB27C;   /* peach text on a solid */
  /* Night: the big dark panels (Today's pick, streak, footer). Darker than the page in dark mode. */
  --night: #1C1A2B;
  --night-edge: transparent;
  --on-night: #FFFFFF;
  --on-night-soft: #CFCAD9;
  --on-night-faint: #A9A2B9;
  --on-night-hover: rgb(255 255 255 / .1);
  --on-ink: #FFFFFF;                               /* text on a strong colour fill (marks, destructive) */

  /* Brand */
  --peach: #FBB27C;                                /* highlighter, logo, active bubble */
  --peach-hover: #FCA466;
  --peach-deep: #E8803D;                           /* decorative only: bubble outlines, days max */
  --on-peach: #1C1A2B;                             /* text on peach, in both themes */
  --on-peach-soft: #4A3B33;
  --peach-ink: #9A4A14;       /* peach text on the page */
  --peach-band: #FEF3EA;      /* hero band */
  --success: #23704A;
  --success-mark: #3FA06C;
  --success-tint: #E6F6EC;
  --danger: #C2455A;
  --danger-mark: #D9566A;
  --danger-tint: #FDECEE;
  --destructive: #B3364B;                          /* destructive button fill, white text on it */
  --destructive-ink: #B3364B; /* destructive text on page, paper or sand */
  --field-line: #8D889A;      /* text-field edge: 3:1 on paper and page */
  --focus: #C4621F;           /* 3:1 on page and paper in both themes */
  --header-bg: rgb(250 250 248 / .86);
  --scrim: rgb(28 26 43 / .45);

  /* Answer letters A–D */
  /* The lines are the area bars, so a letter and its area can't drift apart */
  --letter-a: #FCD9BD;  --letter-a-ink: #8E4512;  --letter-a-line: var(--life-bar);
  --letter-b: #DCD4F8; --letter-b-ink: #4B3A99; --letter-b-line: var(--mind-bar);
  --letter-c: #CDEEDB; --letter-c-ink: #23704A; --letter-c-line: var(--world-bar);
  --letter-d: #F8E7A6;  --letter-d-ink: #6E5106;  --letter-d-line: var(--how-bar);

  /* Areas: bg (tile), blob (fill), ink (text on bg), bar (meters, rules), page (tint) */
  --mind-bg: #EEEAFB;  --mind-blob: #C9BDF5;  --mind-ink: #4B3A99;  --mind-bar: #7E6BD6;  --mind-page: #F6F4FD;
  --life-bg: #FDEBDD;  --life-blob: #FBC59A;  --life-ink: #8E4512;  --life-bar: #E8803D;  --life-page: #FEF6EF;
  --work-bg: #E3F0FA; --work-blob: #A9D2F2; --work-ink: #1F5A86; --work-bar: #3B86C4; --work-page: #F2F7FC;
  --world-bg: #E2F4EA; --world-blob: #A8DFBF; --world-ink: #23704A; --world-bar: #3FA06C; --world-page: #F2F9F5;
  --how-bg: #FBF2D5;   --how-blob: #F4D772;   --how-ink: #6E5106;   --how-bar: #C99A12;   --how-page: #FDF9EC;
  --home-bg: #FCE6E8;   --home-blob: #F6B3BB;   --home-ink: #9A2E3E;   --home-bar: #D9566A;   --home-page: #FDF4F5;

  /* Days grid (5 levels) */
  --days-0: var(--sand-deep);
  --days-1: #FCDCC2;
  --days-2: #FBC59A;
  --days-3: #F5A066;
  --days-4: #E8803D;

  /* Type: Valley Sans for everything; hierarchy from size and weight */
  --font-display: "Valley Sans", "Valley Sans Fallback", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Valley Sans", "Valley Sans Fallback", ui-sans-serif, system-ui, sans-serif;
  --fs-hero: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);
  --fs-page: clamp(2.25rem, 1.6rem + 2.8vw, 3.5rem);
  --fs-h2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-question: clamp(1.375rem, 1.1rem + 1.2vw, 2rem);
  --fs-score: clamp(3rem, 2.2rem + 3vw, 4.5rem);
  --fs-stat: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --fs-h2-sm: clamp(1.375rem, 1.2rem + .8vw, 1.75rem);  /* display titles in cards: mode cards, streak, fact of the day */
  --fs-h3: 1.1875rem;
  --fs-h4: 1.0625rem;
  --fs-lead: clamp(1.0625rem, 1rem + .25vw, 1.1875rem);
  --fs-body: 1rem;
  --fs-label: .9375rem;                            /* subject names in lists, small options, fact text in cards */
  --fs-small: .875rem;
  --fs-xs: .8125rem;
  --fs-tag: .75rem;
  --lh-tight: 1.06;                                /* h1: room for the tilted highlighter when it wraps */
  --lh-head: 1.12;
  --lh-snug: 1.25;                                 /* h3, h4, card titles, answers */
  --lh-body: 1.5;
  --track-display: -.03em;
  --track-head: -.02em;
  --track-snug: -.01em;
  --track-tag: .08em;

  /* Space: 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64 72 80 96 px */
  --s-1: .25rem;  --s-2: .375rem; --s-3: .5rem;   --s-4: .625rem; --s-5: .75rem;  --s-6: .875rem;
  --s-7: 1rem;    --s-8: 1.25rem; --s-9: 1.5rem;  --s-10: 1.75rem; --s-11: 2rem;  --s-12: 2.5rem;
  --s-13: 3rem;   --s-14: 3.5rem; --s-15: 4rem;   --s-16: 4.5rem; --s-17: 5rem;   --s-18: 6rem;
  --section-gap: clamp(4rem, 2.5rem + 5vw, 7.5rem);
  --gutter: clamp(1rem, 4vw, 3rem);
  --content-max: 75rem;
  --quiz-max: 53.75rem;
  --measure: 62ch;
  --tap: 2.75rem;
  --header-h: 4.25rem;
  /* Card padding: one fluid value so every card breathes the same at each width */
  --pad: clamp(var(--s-8), 1rem + 1.5vw, var(--s-9));
  --pad-lg: clamp(var(--s-8), .75rem + 3vw, var(--s-12));
  --pad-xl: clamp(var(--s-8), 5vw, var(--s-14));    /* the quiz card only */

  /* Shape: soft and chunky. The squircle is the signature: logo, letter
     tiles, answer badges, medals, the score. */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 34px;
  --r-pill: 999px;
  --r-note: 8px 8px 22px 8px;
  --squircle: 50% 50% 50% 22%;

  /* Depth: warm shadows in light, plain black in dark; chunky lips on pressable things */
  --shade: rgb(70 45 20 / .06);
  --shade-deep: rgb(70 45 20 / .28);
  --shadow-1: 0 1px 2px var(--shade);
  --shadow-2: 0 1px 2px var(--shade), 0 16px 32px -14px var(--shade-deep);
  --shadow-ink: 0 14px 28px -14px rgb(28 26 43 / .5);
  --lip: 4px;
  --lip-up: 6px;                                   /* hover lift, and the resting lip on the score and the winner */
  --lip-down: 1px;                                 /* pressed */
  --lip-black: #000;                               /* under a dark control that stays dark in both themes */
  --lip-ink: var(--lip-black);
  --lip-paper: #E4DDD0;
  /* Gloss: the light source on printed-sticker fills. Tiles in dark mode take
     a shade instead, so the light icon keeps its contrast. */
  --gloss: #FFFFFF;
  --gloss-tile: #FFFFFF;

  /* Stationery */
  --tape: rgb(251 178 124 / .8);
  --pen-red: #D9566A;
  --butter: #FFF4C7;
  --clip: #8D889A;            /* paper-clip wire */
  --sheet: #FFFFFF;           /* loose sheets under a card */
  --sheet-edge: var(--line);
  /* Two loose sheets showing under a card's bottom-right edge */
  --sheets: 5px 6px 0 -1px var(--sheet), 5px 6px 0 0 var(--sheet-edge), 10px 12px 0 -1px var(--sheet), 10px 12px 0 0 var(--sheet-edge);

  /* Motion */
  --dur-fast: 150ms;
  --dur: 180ms;
  --dur-slow: 300ms;
  --dur-mark: 260ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --ease-pop: cubic-bezier(.3, 1.6, .5, 1);

  /* Rules */
  --rule: 2px;
  --focus-ring: 3px solid var(--focus);
}

/* Area theming: any element with data-area exposes --a-* for its subtree */
[data-area="mind"]  { --a-bg: var(--mind-bg);  --a-blob: var(--mind-blob);  --a-ink: var(--mind-ink);  --a-bar: var(--mind-bar);  --a-page: var(--mind-page); }
[data-area="life"]  { --a-bg: var(--life-bg);  --a-blob: var(--life-blob);  --a-ink: var(--life-ink);  --a-bar: var(--life-bar);  --a-page: var(--life-page); }
[data-area="work"]  { --a-bg: var(--work-bg);  --a-blob: var(--work-blob);  --a-ink: var(--work-ink);  --a-bar: var(--work-bar);  --a-page: var(--work-page); }
[data-area="world"] { --a-bg: var(--world-bg); --a-blob: var(--world-blob); --a-ink: var(--world-ink); --a-bar: var(--world-bar); --a-page: var(--world-page); }
[data-area="how"]   { --a-bg: var(--how-bg);   --a-blob: var(--how-blob);   --a-ink: var(--how-ink);   --a-bar: var(--how-bar);   --a-page: var(--how-page); }
[data-area="home"]  { --a-bg: var(--home-bg);  --a-blob: var(--home-blob);  --a-ink: var(--home-ink);  --a-bar: var(--home-bar);  --a-page: var(--home-page); }
/* Neutral fallback (mixed rounds, no subject) */
:root, [data-area="mixed"] { --a-bg: var(--sand); --a-blob: var(--peach); --a-ink: var(--peach-ink); --a-bar: var(--peach-deep); --a-page: var(--page); }

}

/* ==========================================================================
   Base: fonts, reset, document, type, layout helpers, accessibility
   ========================================================================== */

/* Valley Sans (OFL, fonts/OFL.txt): one variable face, weights 100–900, for
   headings and body. Served as TTF with a Brotli copy, which comes out close
   to WOFF2 on the wire. The fallback is Arial with Valley Sans's vertical
   metrics, so line heights hold while the font loads. */
@font-face {
  font-family: "Valley Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/valley-sans.8bf2cd0673.ttf") format("truetype");
}
@font-face {
  font-family: "Valley Sans Fallback";
  src: local("Arial"), local("ArialMT"), local("Helvetica");
  /* Measured by tools/font-metrics.cs: Arial scaled to Valley Sans's width and line box */
  size-adjust: 108.14%;
  ascent-override: 88.78%;
  descent-override: 22.19%;
  line-gap-override: 0%;
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden]:not([hidden="until-found"]) { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;                 /* Safari 15 has no clip */
  overflow-x: clip;
  /* A thumb that can be seen against the page in both themes (Windows shows it all the time) */
  scrollbar-color: var(--ink-faint) transparent;
}
/* Taps get the site's own pressed states, not the browser's grey flash */
a, button, summary, label { -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  /* Page to page: a short cross-fade where the browser supports it; the header stays put */
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur); }
}

body {
  min-block-size: 100vh;
  min-block-size: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--peach-deep);
  accent-color: var(--ink);
  overflow-x: clip;
}
body > main { flex: 1; }

::selection { background: var(--peach); color: var(--on-peach); }

img, svg { display: block; max-inline-size: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
/* Every disclosure draws its own chevron */
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--lh-head);
  text-wrap: balance;
}
/* One loud thing per screen: the h1 is the only 800; everything under it steps down */
h1 { letter-spacing: var(--track-display); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); font-weight: 720; letter-spacing: var(--track-head); }
h3 { font-size: var(--fs-h3); font-weight: 680; letter-spacing: var(--track-snug); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-h4); font-weight: 650; line-height: var(--lh-snug); }
p, li, dd { text-wrap: pretty; }

.num { font-variant-numeric: tabular-nums; }

/* Focus: one ring everywhere, never removed */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }
/* Headings take focus from script after a screen change, for screen readers; they aren't controls */
[tabindex="-1"]:focus { outline: none; }

/* Layout helpers */
.wrap {
  inline-size: 100%;
  max-inline-size: calc(var(--content-max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--quiz { max-inline-size: calc(var(--quiz-max) + 2 * var(--gutter)); }
.section { margin-block-start: var(--section-gap); }
.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3) var(--s-9);
  margin-block-end: var(--s-11);
}
.section__note { color: var(--ink-muted); font-size: var(--fs-small); }
a.section__note { display: inline-flex; align-items: center; min-block-size: var(--tap); }
/* A bare section heading (no .section__head) over its lead */
.section > h2 + .lead { margin-block-start: var(--s-6); }
.lead { font-size: var(--fs-lead); color: var(--ink-soft); max-inline-size: var(--measure); }

/* The one highlighter stroke per page, behind a phrase in the h1 */
.hl {
  display: inline-block;
  padding: 0 .14em .05em;
  border-radius: .3em .2em .34em .18em;
  background: var(--peach);
  color: var(--on-peach);
  rotate: -2deg;
}

.visually-hidden {
  position: absolute !important;
  inline-size: 1px; block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--s-5);
  inset-block-start: -10rem;
  z-index: 100;
  padding: var(--s-4) var(--s-7);
  border-radius: var(--r-md);
  background: var(--solid);
  color: var(--on-solid);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus-visible { inset-block-start: var(--s-5); }

/* Reduced motion: nothing moves */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* ==========================================================================
   Components. Shared by every page; shown in every state on /styleguide/.
   Playful by rule, not by accident: tilts come from an item's position
   (nth-child), never from randomness, and stay off text, buttons and inputs.
   ========================================================================== */

/* ---------- Motion vocabulary ------------------------------------------------ */
@keyframes pop { from { scale: 0; } to { scale: 1; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
@keyframes spin { to { rotate: 1turn; } }

/* ---------- Header ---------------------------------------------------------- */
.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--line);
}
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-7);
  min-block-size: var(--header-h);
  padding-block: var(--s-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-block-size: var(--tap);
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: 700;
  letter-spacing: var(--track-head);
  text-decoration: none;
}
.brand__mark {
  display: inline-grid;
  place-items: center;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-radius: var(--squircle);
  background: var(--peach);
  rotate: -8deg;
  transition: rotate var(--dur) var(--ease-pop);
}
@media (hover: hover) {
  .brand:hover .brand__mark { rotate: 6deg; }
}
.brand__mark svg { inline-size: 1rem; block-size: 1rem; fill: none; stroke: var(--on-peach); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* The streak sticker: in the header, and on the results card (quiz.css) */
.streak-pill, .results__streak {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--solid);
  color: var(--solid-accent);
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  rotate: -3deg;
}
.streak-pill { min-block-size: var(--tap); }
.streak-pill svg { inline-size: 1rem; block-size: 1rem; }

.site-nav { display: flex; align-items: center; gap: var(--s-1); margin-inline-start: auto; }
.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  padding-inline: var(--s-7);
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-size: var(--fs-small);
  font-weight: 700;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.site-nav__link:hover, .site-nav__link[aria-current="page"] { background: var(--sand); color: var(--ink); }
/* Phones: the nav drops to its own row and the header scrolls away with the
   page, so two rows of chrome don't sit over the content */
@media (max-width: 40rem) {
  .site-header { position: relative; }
  .site-nav { order: 3; inline-size: 100%; margin-inline: calc(-1 * var(--s-4)) 0; }
  .site-header__inner { padding-block-end: var(--s-1); }
}

/* ---------- Footer ---------------------------------------------------------- */
.site-footer { margin-block-start: var(--section-gap); padding-block: var(--s-13); background: var(--night); color: var(--on-night); box-shadow: 0 -1px 0 var(--night-edge); content-visibility: auto; contain-intrinsic-size: auto 14rem; }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-9); }
.site-footer__motto { margin-block-start: var(--s-3); color: var(--on-night-soft); font-size: var(--fs-small); }
.site-footer__org { color: var(--on-night-faint); font-size: var(--fs-small); }
.site-footer__org a { color: var(--on-night-soft); text-underline-offset: .2em; }
.site-footer__org a:hover { color: var(--on-night); }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.site-footer__nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  padding-inline: var(--s-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-small);
  font-weight: 700;
  text-decoration: none;
}
.site-footer__nav a:hover { background: var(--on-night-hover); }
@media (max-width: 40rem) {
  .site-footer { padding-block: var(--s-11); }
  .site-footer__nav { margin-inline: calc(-1 * var(--s-4)); }
}

/* ---------- Icons ----------------------------------------------------------- */
.icon { inline-size: 1.25rem; block-size: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { inline-size: 1rem; block-size: 1rem; }
.icon--lg { inline-size: 1.5rem; block-size: 1.5rem; }
/* Icon on a squircle tile, beside or above a title */
.icon-tile {
  display: inline-grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  border-radius: var(--squircle);
  background: var(--a-blob);
  color: var(--a-ink);
  flex-shrink: 0;
  rotate: -4deg;
}
.icon-tile--sm { inline-size: 2.25rem; block-size: 2.25rem; }
.icon-tile--ink { background: var(--solid); color: var(--solid-accent); }
.icon-tile--peach { background: var(--peach); color: var(--on-peach); }

/* ---------- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-block-size: 3rem;
  padding: var(--s-3) var(--s-9);
  border: var(--rule) solid transparent;
  border-radius: var(--r-pill);
  font-size: var(--fs-body);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-wrap: balance;                 /* long labels ("Read the Environmental Science facts") wrap on phones */
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; }
.btn--sm { min-block-size: var(--tap); padding-inline: var(--s-7); font-size: var(--fs-small); }
.btn--lg { min-block-size: 3.5rem; padding-inline: var(--s-10); font-size: var(--fs-h4); }

.btn--primary { background: var(--solid); color: var(--on-solid); }
.btn--primary:hover:not(:disabled) { box-shadow: var(--shadow-ink); }
.btn--accent, .btn--on-ink { background: var(--peach); color: var(--on-peach); }
.btn--accent:hover:not(:disabled), .btn--on-ink:hover:not(:disabled) { background: var(--peach-hover); }
.btn--secondary { background: var(--sand); color: var(--ink); }
.btn--secondary:hover:not(:disabled) { background: var(--sand-deep); }
.btn--outline { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn--outline:hover:not(:disabled) { background: var(--solid); color: var(--on-solid); }
.btn--destructive { background: var(--destructive); color: var(--on-ink); }

/* Chunky game buttons: a lip underneath that lifts on hover and sinks on press */
.btn--chunky { box-shadow: 0 var(--lip) 0 var(--lip-ink); margin-block-end: var(--lip); }
.btn--chunky.btn--on-ink, .btn--chunky.btn--accent { box-shadow: 0 var(--lip) 0 var(--peach-deep); }
@media (hover: hover) {
  .btn--chunky:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 var(--lip-up) 0 var(--lip-ink); }
  .btn--chunky.btn--on-ink:hover:not(:disabled), .btn--chunky.btn--accent:hover:not(:disabled) { box-shadow: 0 var(--lip-up) 0 var(--peach-deep); }
}
.btn--chunky:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 var(--lip-down) 0 var(--lip-ink); }

.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after {
  content: "";
  inline-size: 1em;
  block-size: 1em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Toggle (save fact): aria-pressed swaps the icon fill and the label */
.toggle .when-on, .toggle[aria-pressed="true"] .when-off { display: none; }
.toggle[aria-pressed="true"] .when-on { display: inline; }
.toggle[aria-pressed="true"] { border-color: var(--solid); background: var(--solid); color: var(--on-solid); }
.toggle[aria-pressed="true"] .icon { fill: currentColor; }

/* ---------- Icon button ----------------------------------------------------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  inline-size: var(--tap);
  block-size: var(--tap);
  border: 0;
  border-radius: var(--r-md);
  background: var(--sand);
  color: var(--ink);
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--sand-deep); }
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.icon-btn:disabled { opacity: .45; }
.icon-btn.toggle[aria-pressed="true"] { background: var(--solid); color: var(--solid-accent); }
.icon-btn.is-done { background: var(--success-tint); color: var(--success); }

/* ---------- Tags, stickers and chips ----------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-4);
  border-radius: var(--r-xs);
  background: var(--sand);
  color: var(--ink-soft);
  font-size: var(--fs-tag);
  font-weight: 700;
  letter-spacing: var(--track-tag);
  line-height: 1.2;
  text-transform: uppercase;
}
/* The ink sticker: Today, Today's pick. Tilted, and it pops in. */
.tag--ink { padding-inline: var(--s-5); border-radius: var(--r-sm); background: var(--solid); color: var(--solid-accent); rotate: -3deg; box-shadow: var(--shadow-1); }
.tag--area { background: var(--a-bg); color: var(--a-ink); }
.tag--locked { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-muted); }
.tag--done { background: var(--success-tint); color: var(--success); rotate: 3deg; }
@media (prefers-reduced-motion: no-preference) {
  .tag--ink, .tag--done { animation: pop 450ms var(--ease-pop) both; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-6) var(--s-1) var(--s-1);
  border-radius: var(--r-pill);
  background: var(--a-bg);
  color: var(--a-ink);
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}
a.chip { min-block-size: var(--tap); }
/* --a-ink on --a-blob falls under 4.5:1 for some areas, so the hover text goes to ink */
a.chip:hover { background: var(--a-blob); color: var(--ink); }

/* ---------- Letter tile: the subject's icon on a tilted squircle ------------- */
/* It only ever holds the subject's SVG (build.ps1 Get-Glyph, core.js subjectGlyph), so no type settings */
.lt {
  display: inline-grid;
  place-items: center;
  inline-size: 2.125rem;
  block-size: 2.125rem;
  border-radius: var(--squircle);
  background: var(--a-blob);
  color: var(--a-ink);
  flex-shrink: 0;
  rotate: -3deg;
}
.lt > .icon { inline-size: 60%; block-size: 60%; stroke-width: 2.3; }
.lt--20 { inline-size: 1.5rem; block-size: 1.5rem; }
.lt--20 > .icon { inline-size: 64%; block-size: 64%; stroke-width: 2.6; }
.lt--28 { inline-size: 1.75rem; block-size: 1.75rem; }
.lt--40 { inline-size: 2.5rem; block-size: 2.5rem; }
/* The big icon on a subject page sits on a solid offset shadow, like a sticker lifted off the sheet */
.lt--64 { inline-size: 4rem; block-size: 4rem; box-shadow: 5px 5px 0 var(--a-bar); }
/* Index-based tilts so neighbours never lean the same way */
:is(.subject-grid, .mastery__list, .pick-grid) > :nth-child(4n+1) .lt { rotate: -5deg; }
:is(.subject-grid, .mastery__list, .pick-grid) > :nth-child(4n+2) .lt { rotate: 4deg; }
:is(.subject-grid, .mastery__list, .pick-grid) > :nth-child(4n+3) .lt { rotate: -3deg; }
:is(.subject-grid, .mastery__list, .pick-grid) > :nth-child(4n) .lt { rotate: 5deg; }

/* ---------- Subject tile ---------------------------------------------------- */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr));
  gap: var(--s-6);
  padding: 0;
  list-style: none;
}
.subject-grid > li { display: flex; }
.subject-tile {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--s-6);
  min-block-size: 4.5rem;
  padding: var(--s-6) var(--s-7);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.subject-tile:hover { background: var(--a-bg); box-shadow: none; }
@media (hover: hover) {
  .subject-tile:hover { transform: translateY(-2px); }
  .subject-tile:hover .lt { rotate: 0deg; transition: rotate var(--dur) var(--ease-pop); }
}
.subject-tile:active { transform: scale(.98); }
.subject-tile[aria-busy="true"] { opacity: .7; cursor: progress; }
.subject-tile__name { display: block; font-size: var(--fs-label); font-weight: 650; line-height: 1.2; }
.subject-tile__count { display: block; color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 500; }
.subject-tile .tag--ink { position: absolute; inset-block-start: calc(-1 * var(--s-4)); inset-inline-end: var(--s-5); }
.subject-tile.is-mastered .lt { background: var(--solid); color: var(--solid-accent); }

/* ---------- Answer badges: A–D, each its own colour ----------------------------- */
.bubble {
  display: inline-grid;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border-radius: var(--squircle);
  background: var(--b-fill, var(--letter-a));
  color: var(--b-ink, var(--letter-a-ink));
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), rotate var(--dur) var(--ease-pop);
}
.bubble--a { --b-fill: var(--letter-a); --b-ink: var(--letter-a-ink); rotate: -4deg; }
.bubble--b { --b-fill: var(--letter-b); --b-ink: var(--letter-b-ink); rotate: 3deg; }
.bubble--c { --b-fill: var(--letter-c); --b-ink: var(--letter-c-ink); rotate: -3deg; }
.bubble--d { --b-fill: var(--letter-d); --b-ink: var(--letter-d-ink); rotate: 4deg; }

/* Pills in a row: progress through a round, results, mastery */
.bubbles { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0; list-style: none; }
.bubbles > * {
  inline-size: 2.5rem;
  block-size: .875rem;
  border-radius: var(--r-pill);
  background: var(--sand-deep);
  transition: background-color var(--dur) var(--ease);
}
.bubbles > .is-right { background: var(--success-mark); }
.bubbles > .is-wrong { background: var(--danger-mark); }
.bubbles > .is-on { background: var(--solid); }
/* The gap ring is the rail's own tint (--a-page; plain page outside a subject) */
.bubbles > .is-current { background: var(--peach); box-shadow: 0 0 0 2px var(--a-page), 0 0 0 4px var(--solid); }
@media (prefers-reduced-motion: no-preference) {
  .bubbles > .is-current { animation: bob 1.6s ease-in-out infinite; }
}
.bubbles--lg > * { inline-size: 2.75rem; block-size: 2.75rem; border-radius: var(--squircle); }
.bubbles--lg > :nth-child(odd) { rotate: -5deg; }
.bubbles--lg > :nth-child(even) { rotate: 4deg; }

/* Mastery pips: ten slim bars, filled up to the best score */
.pips { display: inline-flex; gap: 3px; }
.pips > i { inline-size: .3125rem; block-size: 1rem; border-radius: var(--r-pill); background: var(--sand-deep); }
.pips > i.on { background: var(--a-bar); }
.pips.is-mastered > i.on { background: var(--solid); }

/* ---------- Pen marks ------------------------------------------------------- */
.mark { inline-size: 1.75rem; block-size: 1.75rem; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.mark--tick { stroke: var(--success-mark); }
.mark--cross { stroke: var(--danger-mark); }
.mark path { stroke-dasharray: 40; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .mark.is-drawing path { animation: draw var(--dur-mark) var(--ease) both; }
  .mark.is-drawing path + path { animation-delay: 110ms; }
}
@keyframes draw { from { stroke-dashoffset: 40; } }
/* The red wavy underline a teacher draws under the key phrase */
.pen-underline {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline wavy var(--pen-red);
  text-decoration-thickness: 2px;
  text-underline-offset: .28em;
}

/* ---------- Cards ----------------------------------------------------------- */
.card { position: relative; padding: var(--pad); border-radius: var(--r-xl); background: var(--paper); box-shadow: var(--shadow-1); }
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-7);
  margin-block-end: var(--s-7);
  padding-block-end: var(--s-5);
  border-block-end: var(--rule) dashed var(--a-bar);
}
/* Set in full so an h2 and an h3 card title look the same */
.card__title { font-size: var(--fs-h4); font-weight: 650; letter-spacing: 0; line-height: var(--lh-snug); }
.card--tinted { background: var(--a-bg); box-shadow: none; }
.card--lg { padding: var(--pad-lg); border-radius: var(--r-2xl); }

/* Tape: a peach strip holding a card or note to the page */
.taped::before {
  content: "";
  position: absolute;
  inset-block-start: -.75rem;
  inset-inline-start: 2.25rem;
  z-index: 1;
  inline-size: 4.5rem;
  block-size: 1.375rem;
  border-radius: 2px;
  background: var(--tape);
  rotate: -4deg;
}

/* The deck: two pastel cards peeking out behind a hero or quiz card.
   It goes on a wrapper, never on the card itself: inside the deck's own
   stacking context the cards would paint over the card's background.
   Each variant deals them differently; the quiz re-deals on every question
   (data-deal), and the cards swing to their new place. Offsets scale with
   --spread so phones keep the cards inside the gutter. */
.deck {
  --deck-1: var(--mind-blob); --deck-2: var(--world-blob);
  --deck-r1: 3.5deg; --deck-x1: 10px; --deck-y1: 6px;
  --deck-r2: -2.5deg; --deck-x2: -8px; --deck-y2: 10px;
  --deck-origin: 50% 50%;
  --spread: 1;
  position: relative;
  isolation: isolate;
}
.deck::before, .deck::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--deck-radius, var(--r-2xl));
  transform-origin: var(--deck-origin);
}
.deck::before { background: var(--deck-1); transform: translate(calc(var(--deck-x1) * var(--spread)), var(--deck-y1)) rotate(calc(var(--deck-r1) * var(--spread))); }
.deck::after { background: var(--deck-2); transform: translate(calc(var(--deck-x2) * var(--spread)), var(--deck-y2)) rotate(calc(var(--deck-r2) * var(--spread))); }
@media (prefers-reduced-motion: no-preference) {
  .deck::before, .deck::after { transition: transform 420ms var(--ease-pop), background-color var(--dur-slow) var(--ease); }
}
/* A hand of cards, fanned from the bottom edge */
.deck--fan { --deck-origin: 50% 100%; --deck-r1: 5deg; --deck-x1: 0px; --deck-y1: 0px; --deck-r2: -4.5deg; --deck-x2: 0px; --deck-y2: 0px; }
/* A pile: both cards slid down and to one side */
.deck--pile { --deck-r1: 3deg; --deck-x1: 18px; --deck-y1: 16px; --deck-r2: 1.5deg; --deck-x2: 9px; --deck-y2: 8px; }
/* One card tucked behind, its top edge showing */
.deck--peek { --deck-r1: -3deg; --deck-x1: -4px; --deck-y1: -12px; }
.deck--peek::after { content: none; }
@media (max-width: 40rem) { .deck { --spread: .6; } .results__deck { --spread: .3; } }

/* Loose sheets of paper under a card: two offset edges, no extra elements */
.stack { box-shadow: var(--sheets), var(--shadow-2); }

/* A paper clip over a card's top edge (the d-clip symbol in the sprite) */
.clip {
  position: absolute;
  inset-block-start: -1.25rem;
  inset-inline-end: var(--s-11);
  z-index: 2;
  inline-size: 1.1rem;
  block-size: 3.25rem;
  fill: none;
  stroke: var(--clip);
  stroke-width: 2.2;
  stroke-linecap: round;
  rotate: 10deg;
  pointer-events: none;
}

/* A folded corner: the page colour cut across the top end corner */
.dogear { position: relative; border-start-end-radius: 0; }
.dogear::after {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-end-start-radius: var(--r-sm);
  background: linear-gradient(to bottom left, var(--page) 50%, var(--a-blob) 50%);
  box-shadow: -2px 2px 3px var(--shade);
}
:dir(rtl) .dogear::after { background: linear-gradient(to bottom right, var(--page) 50%, var(--a-blob) 50%); }

/* A rubber stamp: double ruled, tilted, pressed in with a thump */
.stamp {
  display: inline-block;
  padding: .3em .75em;
  border: 3px solid currentColor;
  border-radius: var(--r-sm);
  color: var(--pen-red);
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: .1em;
  line-height: var(--lh-head);
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px currentColor;
  rotate: -8deg;
}
@media (prefers-reduced-motion: no-preference) {
  .stamp { animation: thump 380ms var(--ease) both; }
}
@keyframes thump { from { opacity: 0; scale: 1.7; } 70% { opacity: 1; scale: .94; } }

/* ---------- Mode card ------------------------------------------------------- */
.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-block-size: 13rem;
  padding: var(--pad);
  border: 0;
  border-radius: var(--r-xl);
  background: var(--a-bg);
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
button.mode-card:hover, a.mode-card:hover { box-shadow: var(--shadow-2); }
@media (hover: hover) {
  button.mode-card:hover, a.mode-card:hover { transform: translateY(-3px) rotate(-.6deg); }
}
button.mode-card:active, a.mode-card:active { transform: scale(.98); }
/* Icon to title: 16px in every card (here the card's own gap adds 8) */
.mode-card .icon-tile { margin-block-end: var(--s-3); }
.mode-card__title { display: flex; align-items: baseline; gap: var(--s-4); font-family: var(--font-display); font-size: var(--fs-h2-sm); font-weight: 720; letter-spacing: var(--track-head); line-height: var(--lh-head); }
.mode-card__aside { margin-inline-start: auto; color: var(--a-ink); font-size: var(--fs-h4); font-weight: 650; }
.mode-card__desc { max-inline-size: 34ch; color: var(--ink-soft); font-size: var(--fs-small); }
.mode-card .btn { align-self: flex-start; margin-block-start: auto; }
.mode-card--dark { background: var(--night); color: var(--on-night); box-shadow: inset 0 0 0 1px var(--night-edge), var(--shadow-ink); }
.mode-card--dark .mode-card__desc { color: var(--on-night-soft); }

/* ---------- Track card ------------------------------------------------------ */
.track-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-2) var(--s-6);
  align-content: start;
  inline-size: 100%;
  padding: var(--pad);
  border: 0;
  border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  text-align: start;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.track-card:hover { background: var(--a-bg); box-shadow: none; }
@media (hover: hover) {
  .track-card:hover { transform: translateY(-2px); }
  .track-card:hover .icon-tile { rotate: 6deg; transition: rotate var(--dur) var(--ease-pop); }
}
.track-card:active { transform: scale(.98); }
.track-card[aria-busy="true"] { cursor: progress; opacity: .7; }
.track-card .icon-tile { grid-row: span 3; }
.track-card__title { font-size: var(--fs-h4); font-weight: 650; }
.track-card__arrow { color: var(--a-ink); }
.track-card__desc { grid-column: 2 / -1; color: var(--ink-soft); font-size: var(--fs-small); }
.track-card__subjects { grid-column: 2 / -1; color: var(--a-ink); font-size: var(--fs-xs); font-weight: 600; }

/* ---------- Stat tile ------------------------------------------------------- */
.stat-tile { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--pad); border-radius: var(--r-xl); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1); }
.stat-tile .icon-tile { margin-block-end: var(--s-5); }
.stat-tile__label { color: var(--ink-soft); font-size: var(--fs-small); font-weight: 600; }
.stat-tile__value { font-family: var(--font-display); font-size: var(--fs-stat); font-weight: 700; line-height: var(--lh-head); font-variant-numeric: tabular-nums; }
.stat-tile__value.is-empty { color: var(--ink-muted); }
.stat-tile__hint { color: var(--ink-muted); font-size: var(--fs-xs); }

/* ---------- Trophy ---------------------------------------------------------- */
.trophy {
  position: relative;
  padding: var(--pad);
  border-radius: var(--r-xl);
  box-shadow: inset 0 0 0 var(--rule) var(--line);
}
.trophy__inner { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-6); align-content: start; }
.trophy__seal {
  display: grid;
  place-items: center;
  grid-row: span 2;
  inline-size: 3.25rem;
  block-size: 3.25rem;
  border-radius: var(--squircle);
  background: var(--sand);
  color: var(--ink-faint);
  rotate: -6deg;
}
.trophy:nth-child(even) .trophy__seal { rotate: 5deg; }
.trophy__title { font-size: var(--fs-h4); }
.trophy__desc { color: var(--ink-muted); font-size: var(--fs-small); }
.trophy__progress { display: grid; grid-column: 1 / -1; gap: var(--s-2); margin-block-start: var(--s-4); color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 700; }
.meter { block-size: .4375rem; overflow: hidden; border-radius: var(--r-pill); background: var(--sand); }
.meter > i { display: block; inline-size: 100%; block-size: 100%; border-radius: inherit; background: var(--peach-deep); transform: scaleX(var(--p, 0)); transform-origin: left; }
.trophy.is-unlocked { background: var(--paper); box-shadow: var(--shadow-2); }
.trophy.is-unlocked .trophy__seal { background: var(--peach); color: var(--on-peach); }
.trophy.is-unlocked .trophy__desc { color: var(--ink-soft); }

/* ---------- Fact card ------------------------------------------------------- */
.fact-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-2) var(--s-7);
  padding: var(--pad);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-1);
  content-visibility: auto;
  contain-intrinsic-size: auto 11rem;
  transition: box-shadow var(--dur-fast) var(--ease);
}
.fact-card:hover { box-shadow: var(--shadow-2); }
.fact-card__ref { padding-block-start: .1em; color: var(--ink-muted); font-family: var(--font-display); font-size: var(--fs-h4); font-weight: 700; font-variant-numeric: tabular-nums; }
.fact-card__body { display: grid; gap: var(--s-2); min-inline-size: 0; }
.fact-card__q { color: var(--ink-muted); font-size: var(--fs-small); font-weight: 600; }
/* The answer: the same style as a missed answer on the results screen (.missed__a) */
.fact-card__a { font-family: var(--font-display); font-size: var(--fs-h4); font-weight: 650; line-height: var(--lh-snug); letter-spacing: var(--track-snug); }
.fact-card__fact { margin-block-start: var(--s-3); padding: var(--s-5) var(--s-6); border-radius: var(--r-md); background: var(--a-bg); color: var(--ink-soft); font-size: var(--fs-label); }
.fact-card__tools { display: flex; flex-direction: column; gap: var(--s-3); }
/* Phones: number and tools share the top row, the fact takes the full width under them */
@media (max-width: 34rem) {
  .fact-card { grid-template-columns: 1fr auto; gap: var(--s-3); }
  .fact-card__body { grid-column: 1 / -1; grid-row: 2; }
  .fact-card__tools { flex-direction: row; grid-column: 2; grid-row: 1; }
}

/* ---------- Sticky note ----------------------------------------------------- */
.note {
  position: relative;
  padding: var(--s-9) var(--pad) var(--pad);   /* the top keeps room for the tape */
  border-radius: var(--r-note);
  background: var(--a-bg);
  box-shadow: var(--shadow-1);
}
/* The same strip of tape as .taped, centred */
.note::before {
  content: "";
  position: absolute;
  inset-block-start: -.75rem;
  inset-inline-start: 50%;
  inline-size: 4.5rem;
  block-size: 1.375rem;
  margin-inline-start: -2.25rem;
  border-radius: 2px;
  background: var(--tape);
  rotate: -3deg;
}
:nth-child(odd) > .note, .note:nth-child(odd) { rotate: -.8deg; }
:nth-child(even) > .note, .note:nth-child(even) { rotate: .7deg; }

/* ---------- Search field ---------------------------------------------------- */
.search { position: relative; display: block; inline-size: 100%; max-inline-size: 24rem; }
.search .icon { position: absolute; inset-inline-start: var(--s-7); inset-block: 0; margin-block: auto; color: var(--ink-muted); pointer-events: none; }
.search input {
  inline-size: 100%;
  min-block-size: 3.25rem;
  padding: var(--s-3) var(--s-7) var(--s-3) calc(var(--s-7) + 1.75rem);
  border: var(--rule) solid var(--field-line);
  border-radius: var(--r-pill);
  background: var(--paper);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.search input::placeholder { color: var(--ink-muted); }
.search input:hover { border-color: var(--ink-muted); }
.search input:focus-visible { border-color: var(--ink); }
.search__count { min-block-size: 1.45em; margin-block-start: var(--s-3); color: var(--ink-muted); font-size: var(--fs-small); }

/* ---------- Tabs (aria-pressed pills) --------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s-3); padding: 0; list-style: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-block-size: var(--tap);
  padding-inline: var(--s-7);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--sand);
  color: var(--ink-soft);
  font-size: var(--fs-small);
  font-weight: 700;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.tab:hover { background: var(--sand-deep); color: var(--ink); }
.tab:active { transform: scale(.96); }
.tab[aria-pressed="true"] { background: var(--solid); color: var(--on-solid); }
.tab__dot { inline-size: .625rem; block-size: .625rem; border-radius: var(--squircle); background: var(--a-bar); }

/* ---------- Inline confirm -------------------------------------------------- */
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); }
.confirm__text { margin-inline-end: var(--s-3); color: var(--destructive-ink); font-weight: 700; }

/* ---------- Empty state, skeleton ------------------------------------------- */
.empty { display: grid; justify-items: start; gap: var(--s-4); padding: var(--pad-lg); border-radius: var(--r-xl); box-shadow: inset 0 0 0 var(--rule) var(--line); }
/* Set in full so an h2 and an h3 empty title look the same */
.empty__title { font-size: var(--fs-h3); font-weight: 680; letter-spacing: var(--track-snug); line-height: var(--lh-snug); }
/* An empty state worth looking at: a clipped sheet on a little pile of paper */
.empty--sheet {
  position: relative;
  margin-block-start: var(--s-7);
  background: var(--paper);
  box-shadow: var(--sheets), var(--shadow-2);
  rotate: -.6deg;
}
.empty--sheet .hero__cta { margin-block-start: var(--s-5); }
.empty p { max-inline-size: 48ch; color: var(--ink-soft); }
.skel { display: block; block-size: 1em; border-radius: var(--r-xs); background: var(--sand); }
.skel--line { block-size: .9em; margin-block: .35em; }
.skel--short { inline-size: 60%; }

/* ---------- Toast ----------------------------------------------------------- */
.toast {
  position: fixed;
  inset-block-end: max(var(--s-9), env(safe-area-inset-bottom));
  inset-inline: 0;                    /* centred by auto margins: no translate, which Chrome < 104 lacks */
  z-index: 50;
  inline-size: fit-content;
  max-inline-size: calc(100% - 2 * var(--gutter));
  margin-inline: auto;
  padding: var(--s-5) var(--s-8);
  border-radius: var(--r-pill);
  background: var(--solid);
  color: var(--on-solid);
  font-size: var(--fs-small);
  font-weight: 700;
  box-shadow: var(--shadow-ink);
  translate: 0 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), translate var(--dur) var(--ease-pop);
}
.toast.is-visible { opacity: 1; translate: 0 0; }

/* ---------- Dialog ---------------------------------------------------------- */
.dialog {
  inline-size: min(36rem, 100% - 2 * var(--gutter));
  max-block-size: calc(100vh - 2 * var(--gutter));
  max-block-size: calc(100dvh - 2 * var(--gutter));
  margin: auto;                       /* the reset's margin: 0 would pin a modal to the top left */
  padding: 0;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
/* Before Chrome 122 and Safari 17.4, ::backdrop inherits no custom properties */
.dialog::backdrop { background: var(--scrim, rgb(28 26 43 / .5)); }
.dialog__inner { display: grid; gap: var(--s-8); padding: var(--pad); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-7); }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-4); }
.dialog__foot--start { justify-content: flex-start; }
.dialog__hint { min-block-size: 1.45em; color: var(--ink-soft); font-size: var(--fs-small); }
/* What's new: a short note, narrower than the forms */
.dialog--note { inline-size: min(27rem, 100% - 2 * var(--gutter)); }
.dialog--note .dialog__inner { gap: var(--s-7); }
.dialog--note .dialog__foot { margin-block-start: var(--s-3); }
.note-list { display: grid; gap: var(--s-5); margin: 0; padding: 0; list-style: none; line-height: var(--lh-body); }
.note-list li { display: grid; grid-template-columns: auto 1fr; gap: var(--s-5); align-items: start; }
.note-list__tick {
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border-radius: var(--squircle);
  background: var(--peach);
  color: var(--on-peach);
}
.note-list__tick .icon { inline-size: .875rem; block-size: .875rem; stroke-width: 3; }
.field { display: grid; gap: var(--s-2); padding: 0; border: 0; }
.field__label { font-size: var(--fs-small); font-weight: 700; }
/* The same field as .search input: pill, 3.25rem, a 3:1 edge */
.field input { min-block-size: 3.25rem; padding: var(--s-3) var(--s-7); border: var(--rule) solid var(--field-line); border-radius: var(--r-pill); background: var(--paper); transition: border-color var(--dur-fast) var(--ease); }
.field input:hover { border-color: var(--ink-muted); }
.field input:focus-visible { border-color: var(--ink); }
.pick-grid { display: flex; flex-wrap: wrap; gap: var(--s-3); max-block-size: 18rem; overflow-y: auto; padding: var(--s-2); }
.pick {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-block-size: var(--tap);
  padding: var(--s-1) var(--s-6) var(--s-1) var(--s-1);
  border: var(--rule) solid transparent;
  border-radius: var(--r-pill);
  background: var(--a-bg);
  color: var(--a-ink);
  font-size: var(--fs-small);
  font-weight: 700;
}
/* Ink on the blob: --a-ink on --a-blob falls under 4.5:1 for some areas */
.pick[aria-pressed="true"] { border-color: var(--ink); background: var(--a-blob); color: var(--ink); }
.segmented { display: inline-flex; gap: var(--s-1); padding: var(--s-1); border: 0; border-radius: var(--r-pill); background: var(--sand); }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; }
.segmented span { display: inline-grid; place-items: center; min-inline-size: var(--tap); min-block-size: calc(var(--tap) - 2 * var(--s-1)); padding-inline: var(--s-5); border-radius: var(--r-pill); font-size: var(--fs-small); font-weight: 700; }
.segmented input:checked + span { background: var(--solid); color: var(--on-solid); }
.segmented input:focus-visible + span { outline: var(--focus-ring); outline-offset: 3px; }

/* ---------- Disclosure ------------------------------------------------------ */
.disclosure { border-radius: var(--r-lg); background: var(--sand); }
/* Every disclosure summary: 3rem, var(--s-4) var(--s-7) (also .book__summary, .sample-q) */
.disclosure > summary {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-block-size: 3rem;
  padding: var(--s-4) var(--s-7);
  font-weight: 700;
}
.disclosure > summary .icon { color: var(--peach-ink); transition: rotate var(--dur) var(--ease); }
.disclosure[open] > summary .icon { rotate: 90deg; }
.disclosure__body { display: grid; gap: var(--s-5); padding: 0 var(--s-7) var(--s-7); color: var(--ink-soft); }
.disclosure__body h3 { margin-block-start: var(--s-3); color: var(--ink); font-size: var(--fs-h4); }

/* ---------- Banner (resume) ------------------------------------------------- */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4) var(--s-7); padding: var(--s-6) var(--pad); border-radius: var(--r-xl); background: var(--paper); box-shadow: var(--shadow-2); }
.banner__text { display: grid; flex: 1 1 16rem; }
.banner__title { font-weight: 700; }
.banner__hint { color: var(--ink-muted); font-size: var(--fs-small); }

/* ---------- Stationery in the margins ------------------------------------------ */
/* An answer sheet, a pen tick and an index card, never over the content */
.hero, .page-hero, .subject-hero, .quiz, .results { position: relative; isolation: isolate; }
.decor { position: absolute; inset: 0; z-index: -1; overflow: hidden; overflow: clip; pointer-events: none; }
.decor svg { position: absolute; filter: drop-shadow(0 8px 12px var(--shade-deep)); }
.decor .decor__tick { filter: none; }
.decor__sheet { inline-size: 7.5rem; inset-block-end: 12%; inset-inline-start: max(-1.5rem, calc(50% - 47rem)); rotate: -10deg; }
.decor__tick { inline-size: 4.5rem; inset-block-start: 10%; inset-inline-end: max(1rem, calc(50% - 44rem)); rotate: 8deg; }
.decor__card { inline-size: 8rem; inset-block-end: 8%; inset-inline-end: max(-2rem, calc(50% - 49rem)); rotate: 12deg; }
.decor .ds-line { fill: none; stroke: var(--peach-deep); stroke-width: 2; }
.decor .ds-fill { fill: var(--ink); }
.decor .ds-pen { fill: none; stroke: var(--pen-red); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.decor .ds-card { fill: var(--paper); }
.decor .ds-rule { stroke: var(--pen-red); stroke-width: 1.5; }
.decor .ds-ruled { stroke: var(--work-blob); stroke-width: 1.2; }
@media (max-width: 60rem) { .decor { opacity: .35; } }
/* Page heroes are short: the sheet and the card would sit on the title, so only the pen tick stays */
:is(.page-hero, .subject-hero) :is(.decor__sheet, .decor__card) { display: none; }

/* ---------- Opening and closing ------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .dialog[open] { animation: rise var(--dur-slow) var(--ease-pop); }
  .dialog[open]::backdrop { animation: fade var(--dur) var(--ease); }
  /* Disclosures slide open where the browser can animate to auto */
  @supports (interpolate-size: allow-keywords) {
    :root { interpolate-size: allow-keywords; }
    details::details-content { block-size: 0; overflow: clip; transition: block-size var(--dur-slow) var(--ease), content-visibility var(--dur-slow) allow-discrete; }
    details[open]::details-content { block-size: auto; }
  }
}
@keyframes rise { from { opacity: 0; translate: 0 1rem; scale: .97; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Cards that size themselves to their slot ------------------------------ */
/* Container queries, so a card lays itself out by its own width wherever it sits */
.mode-card, .stat-tile, .trophy { container-type: inline-size; }
@container (max-width: 15rem) {
  .mode-card__desc { font-size: var(--fs-xs); }
  .stat-tile__hint { display: none; }
  .trophy__inner { grid-template-columns: 1fr; }
  .trophy__seal { grid-row: auto; inline-size: 2.5rem; block-size: 2.5rem; }
  .trophy .trophy__title { padding-inline-end: 0; font-size: var(--fs-body); }
  .trophy__tag { display: none; }
  .trophy__desc { font-size: var(--fs-xs); }
}
@container (max-width: 11rem) {
  .stat-tile .icon-tile { display: none; }
  .stat-tile__label { font-size: var(--fs-xs); }
}

/* ---------- Narrow screens ------------------------------------------------------ */
.tag, .modes__resets, .pen-underline, .site-nav__link, .header-cta { white-space: nowrap; }
@media (max-width: 40rem) {
  /* A row that scrolls sideways on phones instead of stacking; it runs to the screen edges */
  .scroll-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    /* A sideways scroller clips top and bottom too, so it gets room for shadows and
       lifted cards, taken back from its neighbours by the negative margins */
    margin-block: calc(var(--s-2) - var(--s-6)) calc(var(--s-5) - var(--s-10));
    margin-inline: calc(-1 * var(--gutter));
    padding: var(--s-6) var(--gutter) var(--s-10);
    scrollbar-width: none;
  }
  .scroll-row::-webkit-scrollbar { display: none; }
  .scroll-row > * { flex-shrink: 0; scroll-snap-align: start; }
  .site-nav { gap: 0; }
  .site-nav__link { padding-inline: var(--s-4); }
  .header-cta { margin-inline-start: auto; }
  /* With a streak showing there's no room for the label: the button keeps its icon and its name */
  .site-header__inner:has(.streak-pill:not([hidden])) .header-cta { inline-size: var(--tap); padding: 0; }
  .site-header__inner:has(.streak-pill:not([hidden])) .header-cta__label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .hide-narrow { display: none; }
  .decor { display: none; }
  /* The area tabs are a .scroll-row (home.html); this row is shorter and snaps loosely */
  .tabs.scroll-row { padding-block: var(--s-2); scroll-snap-type: x proximity; }
  /* Subjects two to a row: icon above the name */
  .subject-grid { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .subject-tile { flex-direction: column; align-items: flex-start; gap: var(--s-4); min-block-size: 0; padding: var(--s-5) var(--s-6) var(--s-6); }
  .subject-tile .tag--ink { inset-block-start: calc(-1 * var(--s-3)); inset-inline-end: var(--s-3); }
  /* Cards and tiles step down one radius together */
  .card, .stat-tile, .mode-card, .empty { border-radius: var(--r-lg); }
  .card--lg { border-radius: var(--r-xl); }
  /* Decks follow the card they sit behind (Today's pick and the streak card: home.css, stats.css) */
  .results__deck, .notfound__deck { --deck-radius: var(--r-xl); }
}
/* No keyboard hints where there's no keyboard */
@media (hover: none) and (pointer: coarse) { .kbd-hint { display: none; } }

/* ---------- Hole-punch confetti (a right answer) ---------------------------------- */
.punch { position: fixed; z-index: 60; inline-size: .625rem; block-size: .625rem; border-radius: 50%; pointer-events: none; }

/* ---------- Windows contrast themes (forced colours) ------------------------------ */
/* The system colours replace ours: shapes drawn only by fill or shadow get an edge,
   and states and data shown only by fill get system colours of their own */
@media (forced-colors: active) {
  :where(.card, .quiz__card, .dialog, .mode-card, .stat-tile, .trophy, .track-card, .fact-card, .note, .banner, .tab, .icon-btn, .subject-tile, .empty) { outline: 1px solid transparent; outline-offset: -1px; }
  .tab[aria-pressed="true"], .pick[aria-pressed="true"], .segmented input:checked + span { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .bubbles > *, .pips > i, .timer__track, .meter { forced-color-adjust: none; background: Canvas; border: 1px solid CanvasText; }
  .bubbles > .is-right, .bubbles > .is-on, .pips > i.on, .timer__track i, .meter > i { background: CanvasText; }
  .bubbles > .is-wrong { background: repeating-linear-gradient(45deg, CanvasText 0 2px, Canvas 0 5px); }
  .bubbles > .is-current { outline: 2px solid Highlight; outline-offset: 2px; }
  .option.is-correct { border-color: Highlight; }
  .days-card { forced-color-adjust: none; }
}

/* ==========================================================================
   Home
   ========================================================================== */

/* Hero: the headline beside a playable sample card on its deck */
.hero {
  padding-block: clamp(var(--s-13), 2rem + 5vw, var(--s-18)) clamp(var(--s-14), 2rem + 5vw, var(--s-18));
  background: var(--peach-band);
}
.hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: clamp(var(--s-12), 6vw, var(--s-17));
  align-items: center;
}
.hero__title { max-inline-size: 11ch; font-size: var(--fs-hero); }
.hero__text .lead { max-inline-size: 44ch; margin-block-start: var(--s-9); }
.hero__cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5); margin-block-start: var(--s-11); }
.hero__sample {
  justify-self: end;
  inline-size: 100%;
  max-inline-size: 29rem;
  rotate: 1deg;
}
@media (max-width: 56rem) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__sample { justify-self: center; max-inline-size: 32rem; rotate: 0deg; }
}
/* Phones: the round is one tap away, so the sample card steps aside and
   Today's pick sits straight under the buttons */
@media (max-width: 40rem) {
  .hero { padding-block: var(--s-11) var(--s-12); }
  .hero__sample { display: none; }
  .hero__text .lead { margin-block-start: var(--s-7); }
  .hero__cta { margin-block-start: var(--s-9); }
  .hero__cta .btn { flex: 1 1 auto; }
}

.sample { display: grid; gap: var(--s-6); align-content: start; min-block-size: 26rem; padding: var(--pad-lg); border-radius: var(--r-2xl); box-shadow: var(--shadow-2); }
.sample__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.sample__head .chip { font-size: var(--fs-xs); }
.sample__try { color: var(--peach-ink); font-size: var(--fs-xs); font-weight: 700; }
.sample__dots { display: flex; gap: var(--s-1); margin-inline-start: auto; padding: 0; list-style: none; }
.sample__dots > li { inline-size: .625rem; block-size: .625rem; border-radius: 50%; background: var(--sand-deep); }
.sample__dots > .is-current { background: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.sample__dots > .is-right { background: var(--success-mark); }
.sample__dots > .is-wrong { background: var(--danger-mark); }
.sample__q { min-block-size: 3.6em; font-family: var(--font-display); font-size: var(--fs-h3); font-weight: 720; line-height: var(--lh-snug); letter-spacing: var(--track-head); }
.sample .options { margin-block-start: 0; }
.sample__after { display: grid; justify-items: start; gap: var(--s-4); }
.sample__fact { padding: var(--s-5) var(--s-6); border-radius: var(--r-md); background: var(--a-bg); color: var(--ink-soft); font-size: var(--fs-small); }

.section--first { margin-block-start: clamp(var(--s-13), 6vw, var(--s-16)); }
.resume { margin-block-start: var(--s-11); }

/* Ways to play */
.modes__grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: var(--s-8); }
/* Today's pick sits on a little pile of cards: peach and the subject's colour */
/* A wide card swings its corners far at the usual pile angles (3deg is about 25px
   per 500px of width), so this pile leans less and steps out by offset instead */
.modes__today { --deck-1: var(--peach); --deck-2: var(--a-bar); --deck-radius: var(--r-xl); --deck-r1: 1.2deg; --deck-r2: .6deg; --deck-x1: 14px; --deck-y1: 14px; --deck-x2: 7px; --deck-y2: 7px; display: grid; }
.modes__today-top { display: flex; align-items: center; gap: var(--s-5); margin-block-end: var(--s-6); }
.modes__today-top .icon-tile { margin: 0; }
.modes__resets { margin-inline-start: auto; color: var(--on-night-faint); font-size: var(--fs-xs); font-weight: 700; }
.modes__today-name { font-size: clamp(1.75rem, 1.5rem + 1vw, 2.25rem); letter-spacing: var(--track-display); }
.modes__more { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-block-start: var(--s-9); }
@media (max-width: 60rem) {
  .modes__grid { grid-template-columns: 1fr 1fr; }
  .modes__today { grid-column: 1 / -1; margin-block-end: var(--s-5); }   /* room for the pile above the row below */
}
/* Phones: Sprint and Random side by side, compact (their container query trims them) */
@media (max-width: 40rem) {
  .modes__grid { gap: var(--s-4); }
  .modes__grid .mode-card { min-block-size: 0; }
  .modes__today { --deck-radius: var(--r-lg); margin-block-end: var(--s-7); }
  .modes__resets { display: none; }
  .modes__more { flex-wrap: nowrap; }   /* a .scroll-row on phones; this file loads after components.css */
}

/* Fact of the day: an index card taped to the page */
.fotd { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-9) var(--s-12); }
.fotd__body { display: grid; flex: 1 1 30rem; justify-items: start; gap: var(--s-5); }
.fotd__title { display: flex; }
.fotd__q { color: var(--ink-muted); font-size: var(--fs-small); }
.fotd__q strong { color: var(--ink); }
.fotd__text {
  min-block-size: 2.4em;
  max-inline-size: 44ch;
  font-family: var(--font-display);
  font-size: var(--fs-h2-sm);
  font-weight: 650;                   /* the same weight as the fact on the quiz note (.fact-note__text) */
  line-height: var(--lh-snug);
  letter-spacing: var(--track-head);
}
.fotd__tools { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* Curated tracks */
.tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--s-8); padding: 0; list-style: none; }
.tracks > li { display: flex; }
/* Phones: one row you swipe through, the next card showing at the edge */
@media (max-width: 40rem) {
  .tracks { display: flex; gap: var(--s-4); }
  .tracks > li { inline-size: min(82%, 19rem); }
  .tracks .track-card__desc { display: none; }
}
.tracks > li:nth-child(odd) .icon-tile { rotate: -7deg; }
.tracks > li:nth-child(even) .icon-tile { rotate: 6deg; }

/* Subjects by area */
#subjects .tabs { margin-block-end: var(--s-3); }
.areas { display: grid; gap: var(--s-13); }
/* Off-screen areas skip layout and paint until scrolled near */
@media (max-width: 40rem) {
  .areas { gap: var(--s-11); }
  .area__head { margin-block-end: var(--s-5); }
  .area__meta { display: none; }
}
.area__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-5); margin-block-end: var(--s-8); }
.area__head h2, .area__head h3 { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-h3); font-weight: 680; letter-spacing: var(--track-head); }
.area__blurb { color: var(--ink-muted); font-size: var(--fs-small); }
.area__meta { margin-inline-start: auto; color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; }

/* The Fact Book panel */
.promo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-7) var(--s-9);
  padding: clamp(var(--s-9), 4vw, var(--s-13));
  border-radius: var(--r-2xl);
  background: var(--peach);
  color: var(--on-peach);
}
.promo__icon { inline-size: 4rem; block-size: 4rem; }
.promo__text { display: grid; flex: 1 1 18rem; gap: var(--s-2); }
.promo__text p { color: var(--on-peach-soft); }
/* The book's page edges: sheets showing under the peach cover */
.promo.stack { box-shadow: var(--sheets); }
/* On peach, the dark controls (primary button, ink icon tile) stay dark in both
   themes, with a black lip; the focus ring turns ink so it shows on peach
   (--focus-ring is resolved on :root, so it is set here, not --focus) */
.promo { --solid: var(--on-peach); --on-solid: var(--on-ink); --solid-accent: var(--peach); --lip-ink: var(--lip-black); --focus-ring: 3px solid var(--on-peach); }

/* About */
.about { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: var(--s-9) var(--s-13); align-items: start; }
.about__body { display: grid; gap: var(--s-8); max-inline-size: var(--measure); color: var(--ink-soft); }
.about__body a { color: var(--ink); text-underline-offset: .2em; }
@media (max-width: 52rem) { .about { grid-template-columns: 1fr; } }

/* ==========================================================================
   Quiz and results screens (home and subject pages)
   ========================================================================== */

/* While playing, the page takes the subject's tint and the chrome steps aside */
/* --play-top is the colour at the top edge; app.js gives it to the status bar */
body.is-playing { --play-top: var(--a-page); background: var(--a-page); }
body.is-playing .site-header,
body.is-playing .site-footer,
body.is-playing .skip-link { display: none; }
/* Pulling down mid-round shouldn't reload the page and lose the round (Android) */
html:has(> body.is-playing) { overscroll-behavior-y: contain; }
@media (prefers-reduced-motion: no-preference) {
  body { transition: background-color var(--dur-slow) var(--ease); }
}

.quiz, .results { padding-block: var(--s-8) var(--s-15); }

/* Rail: quit, progress or timer, score */
.quiz__rail { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-7); margin-block-end: var(--s-12); }
.quiz__rail #btn-quit { background: var(--paper); box-shadow: var(--shadow-1); }
.quiz__progress { display: flex; justify-content: center; min-inline-size: 0; }
.quiz__progress .bubbles { flex-wrap: nowrap; gap: var(--s-2); }
.quiz__progress .bubbles > * { inline-size: clamp(1.1rem, 3.6vw, 2.5rem); block-size: .875rem; }
@media (max-width: 34rem) {
  .quiz__rail { grid-template-columns: auto auto; justify-content: space-between; }
  .quiz__progress { grid-column: 1 / -1; grid-row: 2; }
}

.score-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-block-size: 3rem;
  padding-inline: var(--s-2) var(--s-8);
  border-radius: var(--r-pill);
  background: var(--solid);
  color: var(--on-solid);
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
  white-space: nowrap;
}
.score-pill .icon { box-sizing: content-box; padding: var(--s-2); border-radius: var(--squircle); background: var(--peach); color: var(--on-peach); fill: var(--on-peach); rotate: -8deg; }
.score-float { position: absolute; inset-block-end: 100%; inset-inline-end: var(--s-3); color: var(--success); font-size: var(--fs-small); font-weight: 700; white-space: nowrap; pointer-events: none; animation: score-rise 1.1s var(--ease) forwards; }
@keyframes score-rise {
  from { opacity: 1; translate: 0 .25rem; scale: .6; }
  30% { scale: 1.1; }
  to { opacity: 0; translate: 0 -1.75rem; scale: 1; }
}

.timer { display: flex; align-items: center; gap: var(--s-5); inline-size: min(100%, 26rem); }
.timer__track { flex: 1; block-size: .75rem; overflow: hidden; border-radius: var(--r-pill); background: var(--sand-deep); }
.timer__track i { display: block; block-size: 100%; border-radius: inherit; background: var(--solid); transform-origin: left; }
.timer.is-warn .timer__track i { background: var(--peach-deep); }
.timer.is-danger .timer__track i { background: var(--danger-mark); }
.timer__text { min-inline-size: 3ch; font-family: var(--font-display); font-size: var(--fs-h3); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.is-danger .timer__text { color: var(--danger); }

/* The stage: the question card on its deck. Each question re-deals the deck
   (data-deal 0–3, set by app.js): new colours, new angles, and the cards
   swing across while the new question lands. */
/* Colours mix the subject's two shades with peach and plain paper, so the two cards never match */
.quiz__stage { --deck-1: var(--a-blob); --deck-2: var(--peach); }
.quiz__stage[data-deal="1"] { --deck-1: var(--sheet); --deck-2: var(--a-blob); --deck-r1: -4deg; --deck-x1: -12px; --deck-y1: 8px; --deck-r2: 3deg; --deck-x2: 12px; --deck-y2: 4px; }
.quiz__stage[data-deal="1"]::before { box-shadow: inset 0 0 0 1px var(--sheet-edge); }
.quiz__stage[data-deal="2"] { --deck-1: var(--a-bar); --deck-2: var(--a-blob); --deck-r1: 6deg; --deck-x1: 6px; --deck-y1: 14px; --deck-r2: -5deg; --deck-x2: -6px; --deck-y2: 14px; }
.quiz__stage[data-deal="3"] { --deck-1: var(--a-bar); --deck-2: var(--peach); --deck-r1: 3deg; --deck-x1: 18px; --deck-y1: 16px; --deck-r2: 1.5deg; --deck-x2: 9px; --deck-y2: 8px; }
.quiz__card { padding: var(--pad-xl); border-radius: var(--r-2xl); background: var(--paper); box-shadow: var(--shadow-2); rotate: -.4deg; view-transition-name: quiz-card; }
.quiz__stage:is([data-deal="1"], [data-deal="3"]) .quiz__card { rotate: .5deg; }
/* The next question is dealt in: the old card slides off, the new one lands */
::view-transition-old(quiz-card) { animation: deal-out 260ms var(--ease) both; }
::view-transition-new(quiz-card) { animation: deal-in 360ms var(--ease-pop) both; }
@keyframes deal-out { to { opacity: 0; translate: -14% 2%; rotate: -5deg; } }
@keyframes deal-in { from { opacity: 0; translate: 10% 3%; rotate: 4deg; } }
.quiz__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); margin-block-end: var(--s-10); }
.quiz__meta .chip { padding-inline-end: var(--s-7); font-size: var(--fs-body); }
.quiz__count { margin-inline-start: auto; color: var(--ink-muted); font-size: var(--fs-small); font-weight: 700; font-variant-numeric: tabular-nums; }
.quiz__turn { margin-block-end: var(--s-4); color: var(--a-ink); font-weight: 700; }
.quiz__question { font-size: var(--fs-question); font-weight: 720; letter-spacing: var(--track-head); line-height: var(--lh-head); }

/* Options: chunky, pressable rows with a coloured badge */
.options { display: grid; gap: var(--s-5); margin-block-start: var(--s-11); padding: 0; list-style: none; }
.option {
  display: flex;
  align-items: center;
  gap: var(--s-7);
  inline-size: 100%;
  min-block-size: 4rem;
  padding: var(--s-5) var(--s-8) var(--s-5) var(--s-5);
  border: var(--rule) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  text-align: start;
  box-shadow: 0 var(--lip) 0 var(--lip-paper);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              background-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.option:hover:not(:disabled) { border-color: var(--ink); }
@media (hover: hover) {
  .option:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 var(--lip-up) 0 var(--lip-paper); }
  .option:hover:not(:disabled) .bubble { rotate: 0deg; }
}
.option:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 var(--lip-down) 0 var(--lip-paper); }
.option:disabled { cursor: default; }
.option__text { flex: 1; text-wrap: wrap; }
.option.is-correct { border-color: var(--success-mark); background: var(--success-tint); box-shadow: 0 var(--lip) 0 var(--success-mark); }
/* The badge takes the text-strength green and red so its letter keeps 4.5:1 in both themes */
.option.is-correct .bubble { --b-fill: var(--success); --b-ink: var(--on-solid); }
.option.is-wrong { border-color: var(--danger-mark); background: var(--danger-tint); box-shadow: 0 var(--lip) 0 var(--danger-mark); }
.option.is-wrong .bubble { --b-fill: var(--danger); --b-ink: var(--on-solid); }
.option.is-dimmed { opacity: .5; box-shadow: none; }
@media (prefers-reduced-motion: no-preference) {
  .option.is-wrong { animation: shake 420ms var(--ease); }
  .option.is-correct .bubble { animation: pop 450ms var(--ease-pop); }
}
@keyframes shake {
  15% { translate: -7px 0; }
  35% { translate: 7px 0; }
  55% { translate: -5px 0; }
  75% { translate: 4px 0; }
  100% { translate: 0 0; }
}
@media (max-width: 34rem) {
  .quiz__meta { margin-block-end: var(--s-8); }
  .quiz__count { inline-size: 100%; margin-inline-start: 0; }
  .options { gap: var(--s-4); margin-block-start: var(--s-9); }
  .option { gap: var(--s-5); min-block-size: 3.5rem; padding-inline-end: var(--s-6); font-size: var(--fs-body); }
  .option .bubble { inline-size: 2.125rem; block-size: 2.125rem; }
}
/* Phones, once answered: the two options that played no part fold away, so
   the verdict and the fact come into view without a long scroll */
@media (max-width: 40rem) {
  .options > li:has(> .is-dimmed) { display: none; }
  .quiz .decor, .results .decor { display: none; }
  .quiz, .results { padding-block-start: var(--s-6); }
  .quiz__rail { margin-block-end: var(--s-10); }
  .answer { gap: var(--s-8); margin-block-start: var(--s-9); }
  .answer__next .btn { inline-size: 100%; }
}
.option--sm { min-block-size: 3.25rem; padding-block: var(--s-3); gap: var(--s-5); font-size: var(--fs-label); }
.option--sm .bubble { inline-size: 2rem; block-size: 2rem; font-size: var(--fs-small); }
.option--skel { box-shadow: none; }
.option--skel .skel { flex: 1; }

/* After an answer: verdict sticker, the fact on a sticky note, then Next */
.answer { display: grid; gap: var(--s-9); margin-block-start: var(--s-11); }
.verdict {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-8) var(--s-3) var(--s-4);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: var(--lh-head);
  rotate: -3deg;
}
.verdict.is-right { background: var(--success-tint); color: var(--success); }
.verdict.is-wrong { background: var(--danger-tint); color: var(--danger); rotate: 2deg; }
.verdict .mark { inline-size: 2rem; block-size: 2rem; }
@media (prefers-reduced-motion: no-preference) {
  .answer:not([hidden]) .verdict { animation: pop 450ms var(--ease-pop) both; }
}
.fact-note__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); margin-block-end: var(--s-4); }
.fact-note__title { display: flex; align-items: center; gap: var(--s-3); color: var(--a-ink); font-size: var(--fs-small); font-weight: 700; letter-spacing: var(--track-tag); text-transform: uppercase; }
.fact-note__text { font-family: var(--font-display); font-size: var(--fs-lead); font-weight: 650; line-height: var(--lh-body); }
.fact-note .icon-btn:not([aria-pressed="true"]) { background: var(--paper); }
.answer__next { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-6); }
.answer__hint { color: var(--ink-muted); font-size: var(--fs-small); }
kbd { padding: .1em .45em; border-radius: var(--r-xs); background: var(--sand); box-shadow: inset 0 -2px 0 var(--sand-deep); font-family: inherit; font-size: var(--fs-xs); font-weight: 700; }

/* Results */
/* The results card is held in a fanned hand: the subject's colour and peach */
.results__deck { --deck-1: var(--a-blob); --deck-2: var(--peach); }
.results__card { display: grid; justify-items: center; gap: var(--s-6); text-align: center; box-shadow: var(--shadow-2); }
.results__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-4); }
.results__streak { rotate: 3deg; }        /* the rest is .streak-pill (components.css) */

/* The score on the signature peach squircle */
.score-circle {
  display: inline-flex;
  align-items: baseline;
  margin-block: var(--s-4);
  padding: var(--s-9) var(--s-11);
  border-radius: var(--squircle);
  background: var(--peach);
  color: var(--on-peach);
  font-family: var(--font-display);
  font-size: var(--fs-score);
  font-weight: 700;
  line-height: 1;
  letter-spacing: var(--track-display);
  rotate: -3deg;
  box-shadow: 0 var(--lip-up) 0 var(--peach-deep);
}
.score-circle__of { margin-inline-start: .06em; color: var(--on-peach-soft); font-size: .45em; letter-spacing: 0; }

.results__verdict { font-size: var(--fs-h2); }
.results__sub { max-inline-size: 46ch; color: var(--ink-soft); }
/* A new best is stamped on the card in red ink */
.results__pb { color: var(--peach-ink); font-size: var(--fs-small); font-weight: 700; }
.results__pb.stamp { margin-block: var(--s-2); color: var(--pen-red); font-size: var(--fs-h4); }
.results__row { justify-content: center; margin-block: var(--s-3); }
.results__stats { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-4) var(--s-12); }
.results__stats div { display: grid; }
.results__stats dt { color: var(--ink-muted); font-size: var(--fs-small); font-weight: 700; }
.results__stats dd { font-family: var(--font-display); font-size: var(--fs-stat); font-weight: 700; line-height: var(--lh-head); }
.results__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-4); margin-block-start: var(--s-6); }
@media (max-width: 40rem) {
  .results__actions { inline-size: 100%; }
  .results__actions > .btn { flex: 1 1 8.5rem; padding-inline: var(--s-6); }
  .results__actions > .btn--primary { flex-basis: 100%; }
  /* Ten bubbles on one row, shrinking to fit the card */
  .results__row { gap: var(--s-1); }
  .bubbles--lg > * { inline-size: auto; block-size: auto; flex: 0 1 min(2.75rem, calc((100% - 9 * var(--s-1)) / 10)); aspect-ratio: 1; }
}
.results__next { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-3); color: var(--ink-soft); font-size: var(--fs-small); }

.results__versus { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); inline-size: min(100%, 30rem); margin-block: var(--s-4); }
.versus-side { display: grid; justify-items: center; gap: var(--s-1); padding: var(--pad); border-radius: var(--r-xl); background: var(--sand); rotate: -1.5deg; }
.versus-side + .versus-side { rotate: 1.5deg; }
.versus-side.is-winner { background: var(--peach); color: var(--on-peach); box-shadow: 0 var(--lip-up) 0 var(--peach-deep); }
.versus-side.is-winner .versus-side__of { color: var(--on-peach-soft); }
.versus-side__name { font-weight: 700; overflow-wrap: anywhere; }
.versus-side__score { font-family: var(--font-display); font-size: var(--fs-score); font-weight: 700; line-height: 1; }
.versus-side__of { color: var(--ink-soft); font-size: var(--fs-small); }

/* What you missed: sticky notes */
.results__missed { margin-block-start: var(--s-15); }
.results__missed-sub { margin-block: var(--s-3) var(--s-11); color: var(--ink-soft); }
.missed-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: var(--s-12) var(--s-8); padding: 0; list-style: none; }
.missed { display: grid; align-content: start; justify-items: start; gap: var(--s-3); }
.missed:nth-child(3n+1) { --a-bg: var(--butter); }
.missed__q { color: var(--ink-soft); font-size: var(--fs-small); }
.missed__a { display: flex; align-items: flex-start; gap: var(--s-2); font-family: var(--font-display); font-size: var(--fs-h4); font-weight: 650; line-height: var(--lh-snug); letter-spacing: var(--track-snug); }
.missed__a .mark { inline-size: 1.5rem; block-size: 1.5rem; }
.missed__fact { inline-size: 100%; padding-block-start: var(--s-4); border-block-start: var(--rule) dashed var(--a-bar); }
.missed__save { margin-block-start: var(--s-2); background: var(--paper); }

/* ==========================================================================
   Fact Book, and the page hero shared with My facts and stats
   ========================================================================== */

.page-hero {
  margin-block-end: clamp(var(--s-13), 6vw, var(--s-16));   /* the same gap as .section--first under the home and subject heroes */
  padding-block: clamp(var(--s-12), 5vw, var(--s-15)) clamp(var(--s-11), 4vw, var(--s-13));
  background: var(--peach-band);
}
body[data-area] .page-hero { background: var(--a-page); }
.page-hero h1 { font-size: var(--fs-page); }
.page-hero .lead { margin-block-start: var(--s-6); }
.page-hero__inner--split { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-9); }
.page-hero__inner--split > div { flex: 1 1 28rem; }

/* Index: subjects by area, each tile opens its page */
.book-index { display: grid; gap: var(--s-13); }
@media (max-width: 40rem) { .book-index { gap: var(--s-11); } }

/* Subject page: the list of subjects beside the facts */
.book { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: var(--s-12); align-items: start; }
.book__nav {
  position: sticky;
  inset-block-start: calc(var(--header-h) + var(--s-5));
  max-block-size: calc(100vh - var(--header-h) - var(--s-10));
  max-block-size: calc(100dvh - var(--header-h) - var(--s-10));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-inline-end: var(--s-3);
  scrollbar-width: thin;
}
.book__summary { display: none; }
.book__groups { display: grid; gap: var(--s-8); }
.book__area { display: flex; align-items: center; gap: var(--s-3); margin-block-end: var(--s-2); padding-inline-start: var(--s-4); color: var(--a-ink); font-size: var(--fs-xs); font-weight: 700; }
.book__group ul { padding: 0; list-style: none; }
.book__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-block-size: var(--tap);
  padding-inline: var(--s-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-label);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}
.book__link .num { color: var(--ink-muted); font-size: var(--fs-xs); }
.book__link:hover { background: var(--sand); }
.book__link[aria-current="page"] { background: var(--a-bg); color: var(--a-ink); font-weight: 700; }
.book__link[aria-current="page"] .num { color: var(--a-ink); }

@media (max-width: 60rem) {
  .book { grid-template-columns: 1fr; gap: var(--s-9); }
  .book__nav { position: static; max-block-size: none; overflow: visible; padding: 0; }
  .book__picker { border-radius: var(--r-lg); background: var(--sand); }
  .book__summary {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    min-block-size: 3rem;
    padding: var(--s-4) var(--s-7);
    font-weight: 700;
  }
  .book__summary .icon { color: var(--peach-ink); transition: rotate var(--dur) var(--ease); }
  .book__picker[open] .book__summary .icon { rotate: 90deg; }
  .book__groups { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); padding: 0 var(--s-7) var(--s-7); }
}

.book__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-6) var(--s-8);
  margin-block-end: var(--s-7);
  padding: var(--pad);
  border-radius: var(--r-lg);
  background: var(--a-bg);
}
.book__head-text { flex: 1 1 12rem; }
@media (max-width: 40rem) {
  .book__head .lt--64 { inline-size: 3rem; block-size: 3rem; }
  .book__head .btn { inline-size: 100%; }
  .page-hero__inner--split .search { max-inline-size: none; }
}
.book__title { font-size: var(--fs-h2); }
.book__meta { color: var(--a-ink); font-size: var(--fs-small); font-weight: 700; }
.book .search__count { margin-block: 0 var(--s-4); }
.fact-list { display: grid; gap: var(--s-4); padding: 0; list-style: none; }
.book__more { display: flex; justify-content: center; margin-block-start: var(--s-9); }
.book__more:has(> [hidden]) { display: none; }

/* ==========================================================================
   Stats
   ========================================================================== */

.stats__top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-5); }
@media (max-width: 52rem) { .stats__top { grid-template-columns: 1fr; } }

/* The streak card has a peach card tucked behind it */
.streak-wrap { --deck-1: var(--peach); --deck-radius: var(--r-xl); display: grid; }
.streak-card { justify-content: space-between; gap: var(--s-8); min-block-size: 18rem; }
.streak-card__num .icon { color: var(--peach); }
@media (max-width: 40rem) {
  .streak-card { min-block-size: 0; }
  .streak-wrap { --deck-radius: var(--r-lg); }   /* follows the card, which steps down to --r-lg on phones */
}
.streak-card .icon-tile { margin-block-end: var(--s-7); }   /* icon to title: 16px, as in the mode and stat cards */
.streak-card__title {
  max-inline-size: 16ch;
  font-size: var(--fs-h2-sm);
  line-height: var(--lh-head);
  letter-spacing: var(--track-head);
}
.streak-card__num { display: flex; align-items: baseline; gap: var(--s-4); font-family: var(--font-display); font-size: var(--fs-score); font-weight: 700; line-height: 1; }
.streak-card__unit { color: var(--on-night-soft); font-size: var(--fs-h3); }
.streak-card .mode-card__desc { margin-block-start: var(--s-5); }

/* Always two by two; each tile trims itself by its own width (container query in components.css) */
.stats__tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.stats__tiles > :nth-child(1) { rotate: -.6deg; }
.stats__tiles > :nth-child(4) { rotate: .5deg; }

.mastery-summary { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--s-3) var(--s-9); }
.mastery-summary__num { display: flex; flex-wrap: wrap; align-items: baseline; font-family: var(--font-display); font-size: var(--fs-stat); font-weight: 700; line-height: var(--lh-head); }
.mastery-summary__of { color: var(--ink-muted); }
.mastery-summary__label { flex-basis: 100%; font-family: var(--font-body); font-size: var(--fs-small); font-weight: 700; }
.mastery-summary__row { gap: var(--s-1); }
.mastery-summary__row > * { inline-size: .875rem; block-size: .625rem; }
.mastery-summary .section__note { grid-column: 2; }
@media (max-width: 40rem) {
  .mastery-summary { grid-template-columns: 1fr; }
  .mastery-summary .section__note { grid-column: auto; }
}

/* Useful days: a year of answer-sheet bubbles */
.days-scroll { overflow-x: auto; padding-block-end: var(--s-3); scrollbar-width: thin; }
.days {
  display: grid;
  grid-template-rows: auto repeat(7, .8125rem);
  grid-template-columns: 2.25rem;
  grid-auto-columns: .8125rem;
  grid-auto-flow: column;
  gap: 3px;
  inline-size: max-content;
  color: var(--ink-muted);
  font-size: var(--fs-tag);
  font-weight: 600;
}
.days__month { block-size: 1.3em; white-space: nowrap; }
.days__day { line-height: .8125rem; }
.days i, .days__legend i { display: block; border-radius: 50%; background: var(--days-0); }
.days__legend i { inline-size: .8125rem; block-size: .8125rem; }
.days i.is-today { box-shadow: 0 0 0 2px var(--ink); }
.days i.is-future { visibility: hidden; }
:is(.days, .days__legend) i.d1 { background: var(--days-1); }
:is(.days, .days__legend) i.d2 { background: var(--days-2); }
:is(.days, .days__legend) i.d3 { background: var(--days-3); }
:is(.days, .days__legend) i.d4 { background: var(--days-4); }
.days__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3); margin-block-start: var(--s-5); color: var(--ink-muted); font-size: var(--fs-xs); }
.days__legend { display: flex; align-items: center; gap: 3px; }

/* Subject mastery by area. Each area is a disclosure: open on wide screens,
   folded on phones (stats.js), so the page is six short rows until you look. */
.mastery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: var(--s-5); align-items: start; }
.mastery__area { padding: var(--pad); border-radius: var(--r-xl); background: var(--a-bg); content-visibility: auto; contain-intrinsic-size: auto 22rem; }
/* A folded area is one row: reserving 22rem for it would make the scrollbar jump */
.mastery__area:not([open]) { content-visibility: visible; }
.mastery__head {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
.mastery__head .icon { margin-inline-start: auto; color: var(--a-ink); transition: rotate var(--dur) var(--ease); }
.mastery__area[open] .mastery__head .icon { rotate: 90deg; }
.mastery__area[open] .mastery__head { margin-block-end: var(--s-4); padding-block-end: var(--s-4); border-block-end: var(--rule) dashed var(--a-bar); }
.mastery__head h3 { font-size: var(--fs-h4); }
.mastery__left { color: var(--a-ink); font-size: var(--fs-xs); font-weight: 700; }
@media (max-width: 40rem) {
  .mastery { gap: var(--s-3); }
  .mastery__area { padding: var(--s-5) var(--s-7); border-radius: var(--r-lg); contain-intrinsic-size: auto 4rem; }
  .mastery__head { min-block-size: var(--tap); }
}
.mastery__list { display: grid; gap: var(--s-1); padding: 0; list-style: none; }
.mastery__row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: var(--s-5); min-block-size: var(--tap); }
.mastery__name { font-size: var(--fs-small); font-weight: 650; line-height: 1.2; }
.mastery__link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-inline-size: 3.5rem;
  min-block-size: var(--tap);
  color: var(--a-ink);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.mastery__link:hover { text-decoration: underline; }

/* Trophy cabinet */
.trophies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--s-5);
  min-block-size: 20rem;
  padding: 0;
  list-style: none;
}
.trophy__title { padding-inline-end: var(--s-16); }   /* room for the tag */
.trophy__tag { position: absolute; inset-block-start: var(--s-6); inset-inline-end: var(--s-6); }
/* Phones: two to a row, each trophy compact (container query in components.css) */
@media (max-width: 40rem) {
  .trophies { grid-template-columns: 1fr 1fr; gap: var(--s-3); min-block-size: 0; }
  .trophy { padding: var(--s-6); border-radius: var(--r-lg); }
}

/* Stored on this device */
.device { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-6) var(--s-9); }
.device__action { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-4); max-inline-size: 26rem; }
.setting { display: inline-flex; align-items: center; gap: var(--s-4); min-block-size: var(--tap); margin-block-start: var(--s-3); font-size: var(--fs-small); font-weight: 650; cursor: pointer; }
.setting input { margin: 0; accent-color: var(--success-mark); }   /* native size: Safari draws it as a switch */
.device__text p { max-inline-size: 56ch; margin-block-start: var(--s-2); color: var(--ink-soft); font-size: var(--fs-small); }
@media (max-width: 44rem) {
  .device { grid-template-columns: auto 1fr; }
  .device__action { grid-column: 1 / -1; justify-content: flex-start; max-inline-size: none; }
}

/* ==========================================================================
   Subject landing pages, My facts, 404, styleguide
   ========================================================================== */

/* Subject page */
.subject-hero { padding-block: clamp(var(--s-11), 5vw, var(--s-14)) clamp(var(--s-12), 6vw, var(--s-16)); background: var(--a-page); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0; list-style: none; color: var(--ink-muted); font-size: var(--fs-small); }
.crumbs li + li::before { content: "/"; margin-inline-end: var(--s-2); }
.crumbs a { color: inherit; text-underline-offset: .2em; }
.crumbs [aria-current] { color: var(--ink); font-weight: 700; }
.subject-hero__title { display: flex; align-items: center; gap: var(--s-7); margin-block: var(--s-8) var(--s-6); }
.subject-hero h1 { font-size: var(--fs-page); }
.subject-hero .lead { max-inline-size: 56ch; }
.subject-hero__cta { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-block-start: var(--s-9); }
.subject-hero__best { margin-block-start: var(--s-6); color: var(--a-ink); font-weight: 700; }
@media (max-width: 30rem) { .subject-hero .lt--64 { display: none; } }

.subject-intro { max-inline-size: var(--measure); color: var(--ink-soft); font-size: var(--fs-lead); }
.subject-sample-title { margin-block: var(--s-10) var(--s-5); font-size: var(--fs-h4); }
.subject-sample { display: grid; gap: var(--s-3); padding: 0; list-style: none; counter-reset: q; }
.sample-q { border-radius: var(--r-md); background: var(--a-bg); }   /* --a-bg, like every area panel inside a card */
.sample-q > summary {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  min-block-size: 3rem;
  padding: var(--s-4) var(--s-7);
  font-weight: 700;
}
.sample-q > summary::before { counter-increment: q; content: counter(q, decimal-leading-zero); color: var(--a-ink); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.sample-q > summary::after { content: "Show the answer"; margin-inline-start: auto; color: var(--a-ink); font-size: var(--fs-xs); white-space: nowrap; }
.sample-q[open] > summary::after { content: "Hide"; }
.sample-q > p { padding: 0 var(--s-7) var(--s-6) calc(var(--s-7) + 1.6rem + var(--s-4)); color: var(--ink-soft); }
.sample-q > p strong { color: var(--ink); }

/* My facts */
.myfacts { display: grid; gap: var(--s-9); }
.myfacts__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-9); }
.myfacts__bar .search__count { margin: 0; }
.myfacts__loading { display: grid; gap: var(--s-4); }
#myfacts-list { display: grid; gap: var(--s-13); }
.myfacts__title { display: flex; align-items: center; gap: var(--s-4); margin-block-end: var(--s-8); font-size: var(--fs-h3); }
@media (max-width: 40rem) {
  #myfacts-list { gap: var(--s-11); }
  .myfacts__title { margin-block-end: var(--s-5); }
}
.myfacts__n { padding: var(--s-1) var(--s-3); border-radius: var(--r-pill); background: var(--a-bg); color: var(--a-ink); font-size: var(--fs-small); }
.myfacts .fact-card__ref { display: none; }
.myfacts .fact-card { grid-template-columns: 1fr auto; }

/* 404 */
.notfound { padding-block: var(--section-gap); }
.notfound__deck { --deck-1: var(--a-blob); --deck-2: var(--peach); max-inline-size: 48rem; margin-inline: auto; rotate: -.5deg; }
.notfound__card { display: grid; justify-items: start; gap: var(--s-7); }
.notfound h1 { font-size: var(--fs-page); }
.notfound__stamp { font-size: var(--fs-small); }

/* Styleguide */
.sg { display: grid; gap: var(--s-15); padding-block-end: var(--s-12); }
.sg__section { display: grid; gap: var(--s-8); }
.sg__section > h2 { padding-block-end: var(--s-4); border-block-end: var(--rule) solid var(--line); }
.sg__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5); }
.sg__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--s-5); align-items: start; }
.sg__label { display: block; margin-block-end: var(--s-3); color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 700; }
.sg__swatch { display: grid; gap: var(--s-2); font-size: var(--fs-xs); }
.sg__chip { block-size: 3.5rem; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); }
.sg__type > * + * { margin-block-start: var(--s-5); }
.sg__dark { padding: var(--pad); border-radius: var(--r-lg); background: var(--night); }   /* --ink turns light in dark mode */
.sg .is-hover { border-color: var(--ink); }
.sg .btn.is-hover.btn--primary { box-shadow: var(--shadow-ink); }
.sg .btn.is-hover.btn--secondary { background: var(--sand-deep); }
.sg .is-focus { outline: var(--focus-ring); outline-offset: 3px; }
.sg .is-active { transform: scale(.97); }

/* ==========================================================================
   Effects: gradients, frosted glass, large screens, scroll-linked motion and
   the hooks motion.js relies on. Everything here is optional polish: remove
   this file and the site still works and reads the same.
   ========================================================================== */

/* ---------- Large screens ---------------------------------------------------- */
/* The whole interface grows a little on big monitors (rem-based, so it also
   respects the visitor's own font size setting) */
html { font-size: clamp(100%, 87.5% + .2vw, 115%); }
:root { --content-max: 80rem; }

/* Everything that mixes colours sits behind this check: a var() inside an unknown
   function would win the cascade and then wipe the base colour (Chrome < 111,
   Safari < 16.2). Those browsers keep the flat fills from the other files. */
@supports (color: color-mix(in oklch, red, blue)) {

/* ---------- Gradients ---------------------------------------------------------- */
/* Light falls from the top right of every hero band, in the band's own colour */
.hero {
  background:
    radial-gradient(60rem 30rem at 85% 0%, color-mix(in oklch, var(--peach) 30%, transparent), transparent 70%),
    linear-gradient(180deg, var(--peach-band), var(--page));   /* ends on the page colour: no edge where the hero stops */
}
/* body[data-area] matches facts.css, which would otherwise keep the Fact Book subject pages flat */
body[data-area] .page-hero, .subject-hero {
  background:
    radial-gradient(50rem 22rem at 90% 0%, color-mix(in oklch, var(--a-blob) 26%, transparent), transparent 70%),
    linear-gradient(180deg, var(--a-page), var(--page));
}
body:not([data-area]) .page-hero {
  background:
    radial-gradient(50rem 22rem at 90% 0%, color-mix(in oklch, var(--peach) 28%, transparent), transparent 70%),
    linear-gradient(180deg, var(--peach-band), var(--page));
}
/* While playing, the subject's tint pools at the top of the page */
body.is-playing {
  --play-top: color-mix(in oklch, var(--a-blob) 30%, var(--a-page));
  background: radial-gradient(70rem 40rem at 50% -10%, color-mix(in oklch, var(--a-blob) 35%, var(--a-page)), var(--a-page) 70%) fixed;
}

/* Dark panels: ink deepening into a hint of plum */
.mode-card--dark { background: linear-gradient(150deg, color-mix(in oklch, var(--night), var(--mind-bar) 14%), var(--night) 60%); }
/* Mode cards: the area tint warming towards its fill */
.mode-card:not(.mode-card--dark) { background: linear-gradient(160deg, var(--a-bg) 30%, color-mix(in oklch, var(--a-bg), var(--a-blob) 55%)); }
/* Buttons: a soft top light, like a printed sticker */
.btn--primary { background-image: linear-gradient(180deg, color-mix(in oklch, var(--gloss) 12%, transparent), transparent 60%); }
.btn--accent, .btn--on-ink { background-image: linear-gradient(180deg, color-mix(in oklch, var(--gloss) 35%, transparent), transparent 70%); }
/* The score squircle and the Fact Book panel: peach catching the light */
.score-circle { background: radial-gradient(circle at 30% 25%, color-mix(in oklch, var(--peach), var(--gloss) 30%), var(--peach) 60%, var(--peach-hover)); }
.promo { background: linear-gradient(120deg, var(--peach), color-mix(in oklch, var(--peach), var(--letter-d) 45%)); }
/* Dark tiles take a shade, not a highlight (--gloss-tile), so the light icon keeps 3:1 */
.icon-tile:not(.icon-tile--ink):not(.icon-tile--peach) { background: linear-gradient(145deg, color-mix(in oklch, var(--a-blob), var(--gloss-tile) 25%), var(--a-blob)); }
/* A tile filled on hover fades from its tint into paper */
.subject-tile:hover, .track-card:hover { background: linear-gradient(150deg, var(--a-bg), color-mix(in oklch, var(--a-bg), var(--paper) 60%)); }
/* The highlighter is a marker stroke: denser in the middle, swiped in by motion.js */
.hl {
  background: linear-gradient(100deg, color-mix(in oklch, var(--peach), var(--peach-hover) 40%), var(--peach) 30%, var(--peach) 70%, color-mix(in oklch, var(--peach), var(--peach-hover) 50%)) no-repeat 0 0 / var(--hl, 100%) 100%;
}
/* The sprint timer runs from green through peach to red as it empties */
.timer__track i { background: linear-gradient(90deg, var(--danger-mark), var(--peach-deep) 45%, var(--success-mark)); }
.timer.is-warn .timer__track i, .timer.is-danger .timer__track i { background: linear-gradient(90deg, var(--danger-mark), var(--peach-deep)); }

.toast { background: color-mix(in oklch, var(--solid) 82%, transparent); }

} /* @supports color-mix */

/* ---------- Frosted glass ---------------------------------------------------------- */
.dialog::backdrop { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.toast { -webkit-backdrop-filter: blur(12px) saturate(1.4); backdrop-filter: blur(12px) saturate(1.4); }
.site-header { -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5); }

/* The area tabs stay in reach while you browse the subjects */
#subjects .tabs {
  position: sticky;
  inset-block-start: calc(var(--header-h) + 1px);
  z-index: 10;
  margin-inline: calc(-1 * var(--s-4));
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-pill);
  background: var(--page);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
/* In a round, the rail (quit, progress, score) stays at the top on a frosted strip.
   The strip is a pseudo-element the full width of the window, so it never stops
   short of the edges as a box over the round's tint. */
.quiz__rail {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  margin-inline: calc(-1 * var(--gutter));
  padding: var(--s-4) var(--gutter);
}
.quiz__rail::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline: calc(50% - 50vw);
  z-index: -1;
  background: var(--a-page);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
@media (max-width: 40rem) {
  /* A sticky strip with its own padding: none of .scroll-row's room for shadows */
  #subjects .tabs { inset-block-start: 0; margin-block: 0; margin-inline: calc(-1 * var(--gutter)); border-radius: 0; padding-inline: var(--gutter); }
}

/* ---------- Desktop quiz: question on the left, the answer beside it ---------------- */
/* No scrolling in a round: the fact lands in the empty column next to the options */
.answer-ghost { display: none; }
@media (min-width: 72rem) {
  .wrap--quiz { max-inline-size: calc(78rem + 2 * var(--gutter)); }
  .quiz:not([data-mode="sprint"]) .quiz__card {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    column-gap: clamp(var(--s-12), 4vw, var(--s-16));
    align-items: start;
  }
  .quiz:not([data-mode="sprint"]) .quiz__card > * { grid-column: 1; }
  .quiz:not([data-mode="sprint"]) .quiz__card > :is(.answer, .answer-ghost) { grid-column: 2; grid-row: 1 / span 6; align-self: center; margin-block-start: 0; }
  .quiz:not([data-mode="sprint"]) .answer-ghost { display: grid; }
  .quiz .quiz__card > .answer:not([hidden]) + .answer-ghost { display: none; }
  .answer__next .btn { inline-size: 100%; }
}
/* The empty spot where the fact will be taped */
.answer-ghost {
  place-items: center;
  align-content: center;
  gap: var(--s-4);
  min-block-size: 16rem;
  padding: var(--s-10);
  border: var(--rule) dashed var(--a-bar);
  border-radius: var(--r-note);
  background: var(--a-bg);
  color: var(--ink-muted);
  font-size: var(--fs-small);
  text-align: center;
}
.answer-ghost .icon { inline-size: 2rem; block-size: 2rem; color: var(--a-bar); }
/* See-through versions of the strips and the ghost, where colours can be mixed */
@supports (color: color-mix(in oklch, red, blue)) {
  #subjects .tabs { background: color-mix(in oklch, var(--page) 78%, transparent); }
  .quiz__rail::before { background: color-mix(in oklch, var(--a-page) 75%, transparent); }
  .answer-ghost { border-color: color-mix(in oklch, var(--a-bar) 45%, transparent); background: color-mix(in oklch, var(--a-bg) 45%, transparent); }
}
@media (min-width: 90rem) {
  .book .fact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .stats .trophies { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Hooks for motion.js ------------------------------------------------------ */
/* A deck whose angles motion.js drives skips the CSS easing, which would fight it */
.deck.is-animated::before, .deck.is-animated::after { transition: none; }
/* Cards that lean towards the pointer: depth from the parent, no CSS transform easing */
.tilt-host { perspective: 1100px; }
.is-tilt { transform-style: preserve-3d; will-change: transform; }
.is-tilt.is-tilt { transition: box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease); }
.is-tilt:hover { box-shadow: var(--shadow-2); }

/* ---------- Scroll-linked (native, no script) ------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    /* The header firms up once the page moves */
    .site-header { animation: header-firm linear both; animation-timeline: scroll(root); animation-range: 0 6rem; }
    /* The hero sample drifts up and leans as it leaves */
    .hero__inner { animation: hero-drift linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    /* The quiz rail only frosts once the page has moved under it */
    .quiz__rail::before { animation: rail-frost linear both; animation-timeline: scroll(root); animation-range: 0 3rem; }
    /* The book's page edges fan out as the panel scrolls into view */
    .promo.stack { animation: pages-fan linear both; animation-timeline: view(); animation-range: entry 10% cover 40%; }
  }
}
@keyframes header-firm {
  from { box-shadow: 0 1px 0 transparent; }
  to { box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px var(--shade-deep); }
}
@keyframes rail-frost {
  from { background-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@keyframes hero-drift { to { translate: 0 -3rem; opacity: .4; } }
@keyframes pages-fan {
  from { box-shadow: 1px 1px 0 -1px var(--sheet), 1px 1px 0 0 var(--sheet-edge), 2px 2px 0 -1px var(--sheet), 2px 2px 0 0 var(--sheet-edge); }
  to { box-shadow: 6px 8px 0 -1px var(--sheet), 6px 8px 0 0 var(--sheet-edge), 12px 16px 0 -1px var(--sheet), 12px 16px 0 0 var(--sheet-edge); }
}

/* ==========================================================================
   Print: "Print worksheet" on the results screen sets body.ws-print and prints
   only the worksheet, questions first and the answers on a page of their own.
   Any other print gets the page itself, in the light theme. Print units and
   plain black are deliberate here; nothing on screen uses this file.
   ========================================================================== */
@media print {
  :root { color-scheme: light; }
  body.ws-print > *:not(main), body.ws-print main > *:not(.print-worksheet) { display: none !important; }
  body.ws-print { display: block; background: none; color: #000; }
  body:not(.ws-print) .print-worksheet { display: none !important; }
  .site-header, .site-footer, .decor, .toast, .skip-link, dialog { display: none !important; }
  body.ws-print .print-worksheet { display: block !important; padding: 1.4cm 1.5cm; font-family: Georgia, "Times New Roman", serif; font-size: 11pt; }
  .ws-head h1 { margin: 0 0 4pt; font-size: 17pt; }
  .ws-head p { margin: 0 0 16pt; font-size: 10pt; color: #444; }
  .ws-questions, .ws-answers { margin: 0; padding-left: 1.5em; }
  .ws-questions > li { margin-bottom: 12pt; break-inside: avoid; }
  .ws-questions h3 { margin: 0 0 4pt; font-size: 11pt; font-weight: 600; line-height: 1.35; }
  .ws-questions ol[type="A"] { margin: 4pt 0 0; padding-left: 1.5em; list-style-type: upper-alpha; }
  .ws-questions ol[type="A"] li { margin-bottom: 2pt; font-size: 10pt; }
  .ws-subj { color: #555; font-size: 9pt; font-weight: normal; }
  .ws-key-head { break-before: page; margin: 0 0 8pt; font-size: 14pt; }
  .ws-answers li { margin-bottom: 8pt; font-size: 10pt; line-height: 1.5; break-inside: avoid; }
  .ws-answers em { color: #444; }
}
