/*
 * Whimsical Chrysanthemum Sepia - design system
 * ---------------------------------------------------------------
 * Reskin by editing TOKENS only (section 1 and the theme blocks in
 * section 12). Components below never contain raw colours.
 * No inline styles are needed anywhere; strict CSP (style-src 'self').
 * Contrast ratios are documented in /DESIGN.md.
 */

/* ================================================================
   0. FONTS (self-hosted OFL WOFF2, variable). Fallback stacks are
      used automatically if the files are missing.
   ================================================================ */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/theme/fonts/fraunces-latin-ext-full-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/theme/fonts/fraunces-latin-full-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/theme/fonts/nunito-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/theme/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ================================================================
   1. TOKENS (default theme = Whimsical Chrysanthemum Sepia)
   ================================================================ */
:root {
  /* palette (raw) */
  --parchment: #F9F6EE;        /* EGGSHELL: the page (name kept for stability) */
  --parchment-light: #FFFDF8;  /* ivory surface */
  --sepia: #704214;
  --umber: #4A2E1A;
  --sand: #D9BF9A;
  --gold: #D9A441;
  --rose: #C9776B;
  --sage: #8A9A6B;
  --plum: #6E4E6B;
  --ivory: #FFFDF8;        /* light paper surface */
  --walnut: #3B2A1E;       /* primary ink, 12.66:1 on eggshell */
  --soft-sepia: #5E4A3A;   /* secondary text (soft walnut), 7.73:1 on eggshell */
  --olive: #566B3A;        /* foliage; also choice tile 2 */
  --terracotta: #8A4A3F;   /* choice tile 3 */

  /* semantic colour (required) */
  --color-bg: var(--parchment);
  --color-surface: var(--parchment-light);
  --color-ink: var(--walnut);             /* 12.66:1 on bg */
  --color-ink-soft: var(--soft-sepia);    /* 7.73:1 on bg */
  --color-accent: var(--gold);            /* decoration; umber text on it = 5.50:1 */
  --color-accent-2: var(--rose);          /* decoration only (not for text) */
  --color-success: #4F6B2F;               /* 5.03:1 on bg */
  --color-danger: #A23B2E;                /* 5.46:1 on bg */

  /* semantic colour (extras) */
  --color-primary: #5A3A22;               /* button fill (walnut-sepia) */
  --color-on-primary: var(--parchment-light); /* 10.0:1 on primary */
  --color-on-accent: var(--walnut);
  --color-border: var(--sand);            /* soft decorative border */
  --color-border-strong: #8C6A47;         /* inputs / UI boundaries (4.84:1 on ivory) */
  --color-focus: var(--plum);
  --color-ink-on-dark: var(--parchment-light);

  /* petal / blossom colours used by flower.js (outer -> inner) */
  --petal-1: #E3C27A;
  --petal-2: #D9A441;
  --petal-3: #C9776B;
  --petal-core: #704214;
  --petal-stroke: #704214;
  --petal-fall: #C9776B;

  /* choice tiles: bg + text colour + glyph (colour is never the only cue) */
  --choice-1: #6E4E6B; --choice-1-ink: #FBF5EA; /* plum    5.90 w/ parchment */
  --choice-2: #566B3A; --choice-2-ink: #FBF5EA; /* leaf    4.91+ */
  --choice-3: #8A4A3F; --choice-3-ink: #FBF5EA; /* clay    5.59+ */
  --choice-4: #D9A441; --choice-4-ink: #4A2E1A; /* gold    5.50 */
  --choice-5: #704214; --choice-5-ink: #FBF5EA; /* sepia   7.81 */
  --choice-6: #3F5F73; --choice-6-ink: #FBF5EA; /* dusk    5.65+ */

  /* glyph shapes (mask images, viewBox 24). Swap to reskin. */
  --glyph-1: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2'/%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2' transform='rotate(60 12 12)'/%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2' transform='rotate(120 12 12)'/%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2' transform='rotate(180 12 12)'/%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2' transform='rotate(240 12 12)'/%3E%3Cellipse cx='12' cy='6' rx='3.2' ry='5.2' transform='rotate(300 12 12)'/%3E%3C/g%3E%3C/svg%3E");
  --glyph-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='12,1 23,12 12,23 1,12'/%3E%3C/svg%3E");
  --glyph-3: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10.5'/%3E%3C/svg%3E");
  --glyph-4: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='12,2 23,22 1,22'/%3E%3C/svg%3E");
  --glyph-5: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='2' width='20' height='20' rx='2'/%3E%3C/svg%3E");
  --glyph-6: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='12,1.2 15.1,8.7 23.2,9.4 17,14.6 18.9,22.5 12,18.3 5.1,22.5 7,14.6 0.8,9.4 8.9,8.7'/%3E%3C/svg%3E");

  /* typography (required) */
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display-variation: "SOFT" 100, "WONK" 1;          /* headings */
  --display-title-variation: "SOFT" 100, "WONK" 1, "opsz" 144;  /* titles only: expressive, high optical size */
  --text-variation: "SOFT" 0, "WONK" 0;              /* questions: calm classical serif */
  --fs-base: 1.125rem;
  --fs-small: 0.9375rem;
  --fs-h1: clamp(2rem, 1.2rem + 3.5vw, 3.5rem);
  --fs-h2: clamp(1.5rem, 1.1rem + 1.8vw, 2.25rem);
  --fs-h3: 1.25rem;
  --fs-big-question: clamp(2rem, 1rem + 4.4vw, 5.5rem);
  --fs-room-code: clamp(3.25rem, 1rem + 11vw, 10rem);

  /* spacing (required) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* shape and depth (required) */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.75rem;
  --shadow-soft: 0 2px 4px rgba(74, 46, 26, 0.12), 0 10px 24px -8px rgba(74, 46, 26, 0.28);
  --touch: 3.5rem;       /* 56px minimum tap target */

  /* motion (required) */
  --dur-fast: 150ms;
  --dur-med: 320ms;
  --dur-slow: 700ms;
  --ease: cubic-bezier(0.3, 0.7, 0.3, 1);
  --motion-drift: 1;     /* 0 hides drifting petals */

  /* paper texture + vignette */
  --paper-texture: url("/theme/art/paper.png?v=68f17acd");
  --wash: url("/theme/art/wash-default.png?v=68f17acd");
  --vignette: rgba(59, 42, 30, 0.07);
  --flourish-opacity: 0.9;
}

/* ================================================================
   2. BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  isolation: isolate;
  background-color: var(--color-bg);
  background-image: var(--wash), var(--paper-texture);
  background-size: cover, 256px 256px;
  background-position: center, 0 0;
  background-repeat: no-repeat, repeat;
  background-attachment: fixed, scroll;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-slow) var(--ease), color var(--dur-slow) var(--ease);
}
/* soft vignette sits behind content, above the page background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, var(--vignette) 130%);
}
h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
  font-optical-sizing: auto;
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  color: var(--color-ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); font-variation-settings: var(--display-title-variation); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0; }
a { color: var(--color-primary); text-underline-offset: 0.2em; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--color-accent); color: var(--color-on-accent); }
[hidden] { display: none !important; }

/* ================================================================
   3. LAYOUT PRIMITIVES
   ================================================================ */
.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: var(--space-5);
  isolation: isolate;
  overflow-x: clip;
}
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }
.muted { color: var(--color-ink-soft); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.center { text-align: center; align-items: center; justify-content: center; }
.display { font-family: var(--font-display); }

/* ================================================================
   4. CARDS
   ================================================================ */
.card {
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--space-5);
}
/* .card--deckle is TRANSPARENT: it groups a form or message directly on the page backdrop
   (login, PIN, join). No fill, no border, no shadow, no clip-path, so there is never a box
   whose colour mismatches the paper behind it. Text and inputs are checked against the
   darkest pixel of every theme wash + paper texture (ink >= 7.0:1, ink-soft >= 4.5:1).
   Need a visible panel? Use .card--filled (explicit, deliberate). */
.card--deckle {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: var(--space-4) 0;
}
/* Explicit filled panel (QR card, pack cards, anything that must read as paper on paper). */
.card--filled {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--space-5);
}

/* ================================================================
   5. BUTTONS AND FORM FIELDS
   ================================================================ */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 var(--space-6);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  font: 800 1.125rem/1.2 var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 0 var(--color-border-strong);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-med) var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--color-border-strong); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--color-border-strong); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 var(--color-border-strong); }
.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-ink);
  box-shadow: 0 3px 0 var(--color-ink);
}
.btn--primary:hover { box-shadow: 0 5px 0 var(--color-ink); }
.btn--primary:active { box-shadow: 0 1px 0 var(--color-ink); }
.btn--primary:disabled { box-shadow: 0 3px 0 var(--color-ink); }
.btn--ghost { background: transparent; box-shadow: none; border-color: var(--color-border-strong); color: var(--color-ink); }
.btn--ghost:hover { background: var(--color-surface); box-shadow: none; }
.btn--ghost:active { box-shadow: none; }
.btn--lg { min-height: 4.5rem; padding: 0 var(--space-7); font-size: 1.5rem; border-radius: var(--radius-lg); }

.label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 800;
  font-size: var(--fs-small);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
}
.input {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  font: 600 1.25rem/1.3 var(--font-body);   /* >=16px stops iOS zoom */
  box-shadow: inset 0 2px 4px rgba(74, 46, 26, 0.1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--color-ink-soft); opacity: 0.75; }
.input:focus { outline: none; border-color: var(--color-focus); box-shadow: 0 0 0 4px var(--color-accent); }
.input:focus-visible { outline: none; }
.spell-input {
  display: block;
  width: 100%;
  min-height: 4.5rem;
  padding: var(--space-3) var(--space-4);
  border: 3px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-ink);
  font: 700 clamp(1.75rem, 7vw, 2.5rem)/1.2 var(--font-display);
  font-variation-settings: var(--display-variation);
  text-align: center;
  letter-spacing: 0.04em;
  box-shadow: inset 0 2px 6px rgba(74, 46, 26, 0.14);
}
.spell-input:focus { outline: none; border-color: var(--color-focus); box-shadow: 0 0 0 5px var(--color-accent); }

/* ================================================================
   6. BIG SCREEN (host)
   ================================================================ */
.big-question {
  font-family: var(--font-display);
  font-variation-settings: var(--text-variation);
  font-weight: 600;
  font-size: var(--fs-big-question);
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  color: var(--color-ink);
}
.room-code {
  display: inline-block;
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
  font-weight: 800;
  font-size: var(--fs-room-code);
  line-height: 1;
  letter-spacing: 0.14em;
  padding: 0.12em 0.2em 0.12em 0.34em;  /* optical centre against trailing letter-spacing */
  background: var(--color-surface);
  color: var(--color-ink);
  border: 4px dashed var(--color-accent);
  border-radius: var(--radius-lg);
  text-align: center;
  user-select: all;
  font-variant-numeric: lining-nums tabular-nums;
}
.qr-frame {
  display: inline-block;
  padding: var(--space-4);
  background: #FFFFFF;           /* QR needs a light quiet zone: never themed */
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  line-height: 0;
}
.qr-frame img, .qr-frame svg {
  display: block;
  width: clamp(9rem, 22vw, 20rem);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
}

/* ================================================================
   7. PLAYERS
   ================================================================ */
.player-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  min-height: 2.5rem;
  padding: var(--space-1) var(--space-4) var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  font-weight: 800;
  color: var(--color-ink);
  box-shadow: 0 2px 0 var(--color-border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: chip-in var(--dur-slow) var(--ease) both;
}
.player-chip::before {
  content: "";
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--color-accent);
  -webkit-mask: var(--glyph-1) center / contain no-repeat;
          mask: var(--glyph-1) center / contain no-repeat;
}
.player-chip--disconnected { opacity: 0.6; border-style: dashed; box-shadow: none; font-weight: 600; color: var(--color-ink-soft); }
.player-chip--disconnected::before { background: var(--color-ink-soft); }
@keyframes chip-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ================================================================
   8. ANSWER TILES
   ================================================================ */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
  width: 100%;
}
.choice {
  --_bg: var(--choice-1);
  --_ink: var(--choice-1-ink);
  --gap: 0.9rem;
  --gw: 2.25rem;
  position: relative;
  appearance: none;
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: 100%;
  min-height: 4.5rem;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--gap);
  /* printed index tab: coloured glyph band on ivory stock, text in ink (colour is never the only cue) */
  background: linear-gradient(90deg, var(--_bg) 0, var(--_bg) calc(var(--gw) + var(--gap) * 2), var(--color-surface) calc(var(--gw) + var(--gap) * 2));
  color: var(--color-ink);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font: 700 clamp(1.125rem, 1rem + 0.8vw, 1.75rem)/1.25 var(--font-body);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 0 rgba(74, 46, 26, 0.25);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), opacity var(--dur-med) var(--ease), filter var(--dur-med) var(--ease);
}
.choice[data-i="0"] { --_bg: var(--choice-1); --_ink: var(--choice-1-ink); }
.choice[data-i="1"] { --_bg: var(--choice-2); --_ink: var(--choice-2-ink); }
.choice[data-i="2"] { --_bg: var(--choice-3); --_ink: var(--choice-3-ink); }
.choice[data-i="3"] { --_bg: var(--choice-4); --_ink: var(--choice-4-ink); }
.choice[data-i="4"] { --_bg: var(--choice-5); --_ink: var(--choice-5-ink); }
.choice[data-i="5"] { --_bg: var(--choice-6); --_ink: var(--choice-6-ink); }
.choice:hover { transform: translateY(-1px); box-shadow: 0 4px 0 rgba(74, 46, 26, 0.25); }
.choice:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(74, 46, 26, 0.25); }
.choice__glyph {
  flex: none;
  width: var(--gw);
  height: var(--gw);
  margin-right: var(--gap);
  color: var(--_ink);
  background: currentColor;
  -webkit-mask: var(--glyph-1) center / contain no-repeat;
          mask: var(--glyph-1) center / contain no-repeat;
}
.choice[data-i="0"] .choice__glyph { -webkit-mask-image: var(--glyph-1); mask-image: var(--glyph-1); }
.choice[data-i="1"] .choice__glyph { -webkit-mask-image: var(--glyph-2); mask-image: var(--glyph-2); }
.choice[data-i="2"] .choice__glyph { -webkit-mask-image: var(--glyph-3); mask-image: var(--glyph-3); }
.choice[data-i="3"] .choice__glyph { -webkit-mask-image: var(--glyph-4); mask-image: var(--glyph-4); }
.choice[data-i="4"] .choice__glyph { -webkit-mask-image: var(--glyph-5); mask-image: var(--glyph-5); }
.choice[data-i="5"] .choice__glyph { -webkit-mask-image: var(--glyph-6); mask-image: var(--glyph-6); }
.choice__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* states (shared by .order-item) */
.choice.is-selected, .order-item.is-selected {
  outline: 5px solid var(--color-ink);
  outline-offset: 3px;
  transform: translateY(-3px) scale(1.02);
  border-color: var(--color-surface);
}
.choice.is-selected::after, .order-item.is-selected::after {
  content: "\2713";           /* check mark: selection is not colour-only */
  position: absolute;
  top: -0.9rem; right: -0.6rem;
  display: grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--color-ink);
  color: var(--color-surface);
  font: 900 1.1rem/1 var(--font-body);
}
.choice.is-correct, .order-item.is-correct {
  border-color: var(--color-surface);
  outline: 6px solid var(--color-success);
  outline-offset: 3px;
  animation: settle var(--dur-slow) var(--ease) both;
}
.choice.is-correct::after, .order-item.is-correct::after {
  content: "\2713";
  position: absolute;
  top: -0.9rem; right: -0.6rem;
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  background: var(--color-success);
  color: #FBF5EA;
  font: 900 1.3rem/1 var(--font-body);
}
.choice.is-wrong, .order-item.is-wrong {
  opacity: 0.6;
  filter: saturate(0.5);
  outline: 4px dashed var(--color-danger);
  outline-offset: 3px;
  background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(0, 0, 0, 0.1) 10px 14px), linear-gradient(90deg, var(--_bg) 0, var(--_bg) calc(var(--gw) + var(--gap) * 2), var(--color-surface) calc(var(--gw) + var(--gap) * 2));
}
.choice.is-wrong::after, .order-item.is-wrong::after {
  content: "\2717";
  position: absolute;
  top: -0.9rem; right: -0.6rem;
  display: grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--color-danger);
  color: #FBF5EA;
  font: 900 1.1rem/1 var(--font-body);
}
.choice.is-locked, .order-item.is-locked, .choice:disabled {
  pointer-events: none;
  cursor: default;
  transform: none;
  box-shadow: 0 2px 0 rgba(74, 46, 26, 0.45);
}
.choice.is-locked:not(.is-selected):not(.is-correct):not(.is-wrong) { opacity: 0.7; filter: saturate(0.65); }
@keyframes settle { 0% { transform: scale(0.97); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* true / false: two big tiles. Put .choice[data-i="0"] (True) and [data-i="1"] (False) inside. */
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); width: 100%; }
.tf-grid .choice {
  background: var(--_bg);
  color: var(--_ink);
  flex-direction: column;
  justify-content: center;
  min-height: clamp(8rem, 28vh, 14rem);
  text-align: center;
  font-size: clamp(1.5rem, 1rem + 3vw, 2.5rem);
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
}
.tf-grid .choice__glyph { width: 3rem; height: 3rem; margin: 0; }
.tf-grid .choice__text { flex: none; }

/* ordering */
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); counter-reset: none; }
.order-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 4rem;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  color: var(--color-ink);
  border: 3px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: clamp(1.0625rem, 1rem + 0.6vw, 1.5rem);
  box-shadow: 0 3px 0 var(--color-border-strong);
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-med) var(--ease);
}
/* position badge: reads the visible 1-based number from data-pos */
.order-item::before {
  content: attr(data-pos);
  flex: none;
  display: grid; place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font: 900 1.2rem/1 var(--font-display);
}
.order-item__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.order-item__controls { display: flex; gap: var(--space-2); flex: none; }
.order-item__controls .btn { min-width: var(--touch); padding: 0; }

/* ================================================================
   9. TIMER, SCORES, PODIUM
   ================================================================ */
.timer {
  position: relative;
  display: inline-block;
  width: var(--timer-size, clamp(7rem, 16vw, 13rem));
  aspect-ratio: 1;
  line-height: 0;
}
.timer svg { display: block; width: 100%; height: 100%; overflow: visible; }
.timer__seconds {
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
  font-weight: 800;
  fill: var(--color-ink);
}
.timer__disc { fill: var(--color-surface); stroke: var(--color-accent); stroke-width: 3; }
.timer--small { --timer-size: 4.5rem; }

.scoreboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); width: 100%; counter-reset: rank; }
.scoreboard__row {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 3.5rem;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: clamp(1.125rem, 1rem + 0.9vw, 2rem);
  animation: chip-in var(--dur-slow) var(--ease) both;
}
.scoreboard__row::before {
  content: counter(rank);
  flex: none;
  display: grid; place-items: center;
  width: 2.25em; height: 2.25em;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font: 900 0.9em/1 var(--font-display);
}
.scoreboard__row:nth-child(1) { border-color: var(--color-accent); border-width: 3px; }
.scoreboard__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard__score { flex: none; font-variant-numeric: tabular-nums; color: var(--color-ink-soft); }
.scoreboard__row.is-you { background: var(--color-accent); color: var(--color-on-accent); border-color: var(--color-ink); }
.scoreboard__row.is-you .scoreboard__score { color: var(--color-on-accent); }
.scoreboard__row.is-you::before { background: var(--color-ink); color: var(--color-surface); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: var(--space-3); width: 100%; min-height: clamp(12rem, 40vh, 26rem); }
.podium__step {
  flex: 1 1 0;
  max-width: 16rem;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-2);
  text-align: center;
  font-weight: 800;
  font-size: clamp(1rem, 0.8rem + 1.2vw, 2rem);
  color: var(--color-ink);
  background: var(--color-surface);
  border: 3px solid var(--color-border-strong);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-wrap: anywhere;
  animation: rise var(--dur-slow) var(--ease) both;
}
.podium__step::before { font: 900 2em/1 var(--font-display); }
.podium__step--1 { order: 2; min-height: 100%; height: clamp(12rem, 40vh, 26rem); background: var(--color-accent); color: var(--color-on-accent); animation-delay: 500ms; }
.podium__step--2 { order: 1; height: clamp(9rem, 30vh, 20rem); animation-delay: 250ms; }
.podium__step--3 { order: 3; height: clamp(7rem, 22vh, 15rem); }
.podium__step--1::before { content: "1"; }
.podium__step--2::before { content: "2"; }
.podium__step--3::before { content: "3"; }
.podium__name { overflow-wrap: anywhere; }
.podium__score { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* ================================================================
   10. FEEDBACK + QUOTE
   ================================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  z-index: 100;
  max-width: min(32rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-5);
  background: var(--color-ink);
  color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  font-weight: 800;
  text-align: center;
  animation: toast-in var(--dur-med) var(--ease) both;
}
.toast--error { background: var(--color-danger); color: #FBF5EA; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

.locked-in {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-success);
  color: #FBF5EA;                 /* 5.57:1 */
  border-radius: 999px;
  font: 800 1.25rem/1.2 var(--font-body);
  animation: bob 4s ease-in-out infinite;
}
.locked-in::before { content: "\2713"; font-weight: 900; }

.quote {
  position: relative;
  margin: 0;
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
  font-size: clamp(1.375rem, 1rem + 1.8vw, 2.5rem);
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  color: var(--color-ink);
  border-top: 2px solid var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
}
.quote::before { content: "\201C"; display: block; font-size: 2.5em; line-height: 0.6; color: var(--color-accent-2); }
.quote__source {
  display: block;
  margin-top: var(--space-3);
  font: 700 var(--fs-small)/1.3 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
}
.quote__source::before { content: "\2014\00a0"; }

/* ================================================================
   11. BLOSSOM MOTIFS (flower.js)
   ================================================================ */
.blossom { display: block; max-width: 100%; height: auto; }
.fl-p0 { fill: var(--petal-1); } .fl-p1 { fill: var(--petal-2); } .fl-p2 { fill: var(--petal-3); }
.fl-p3 { fill: var(--petal-1); } .fl-p4 { fill: var(--petal-2); } .fl-p5 { fill: var(--petal-3); }
.fl-stroke { stroke: var(--petal-stroke); fill-opacity: 0.96; }
.fl-core { fill: var(--petal-core); }
.fl-vein { stroke: var(--petal-stroke); }
.fl-fall { fill: var(--petal-fall); }
.blossom--spin { animation: spin 90s linear infinite; }
.bob { animation: bob 5s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }

.has-flourish { position: relative; isolation: isolate; }
.decor-layer { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.decor-layer--fixed { position: fixed; }
.flourish {
  --fl: clamp(11rem, 30vw, 28rem);
  position: absolute;
  width: var(--fl);
  height: var(--fl);
  pointer-events: none;
  opacity: var(--flourish-opacity);
}
.flourish img { display: block; width: 100%; height: 100%; transform-origin: 0 0; }
.flourish--tl { top: 0; left: 0; }                                   /* the large cluster: ONE corner */
.flourish--br { --fl: clamp(9rem, 20vw, 18rem); width: var(--fl); height: auto; aspect-ratio: 640 / 300; right: 0; bottom: 14%; }   /* smaller branch from the opposite edge */
.flourish--br img { transform: scaleX(-1); transform-origin: center; }
.flourish--bl { --fl: clamp(3.5rem, 8vw, 7rem); left: -1.8rem; bottom: 22%; }                                            /* the odd single blossom */
.flourish--tr { --fl: clamp(2.6rem, 5vw, 4.6rem); top: 16%; right: 1.4rem; rotate: 14deg; }                /* a single bud accent */
.flourish--tl img, .flourish--br img { animation: sway 22s ease-in-out infinite alternate; }
@keyframes sway { from { rotate: -1.2deg; } to { rotate: 1.2deg; } }

.drift {
  position: absolute;
  top: -8%;
  width: 2.4rem;
  height: 2.4rem;
  pointer-events: none;
  opacity: 0;
  animation: drift 22s linear infinite;
  animation-delay: var(--drift-delay, 0s);
}
.drift img { display: block; width: 100%; height: 100%; object-fit: contain; }
.drift--1 { left: 8%;  --drift-delay: -2s;  animation-duration: 24s; }
.drift--2 { left: 24%; --drift-delay: -9s;  animation-duration: 28s; }
.drift--3 { left: 43%; --drift-delay: -15s; animation-duration: 21s; }
.drift--4 { left: 61%; --drift-delay: -5s;  animation-duration: 30s; }
.drift--5 { left: 78%; --drift-delay: -12s; animation-duration: 25s; }
.drift--6 { left: 92%; --drift-delay: -19s; animation-duration: 27s; }
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.65; }
  50%  { transform: translate(40px, 55vh) rotate(140deg); opacity: 0.55; }
  92%  { opacity: 0.4; }
  100% { transform: translate(-30px, 112vh) rotate(300deg); opacity: 0; }
}
.burst-host { position: relative; }
.burst-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 50; }
.burst-layer svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }

/* ================================================================
   12. OCCASION THEMES  (body[data-theme="id"])
   Only tokens change. Every text pairing stays >= 4.5:1.
   ================================================================ */
[data-theme="default"] { /* uses :root */ }
[data-theme="naw-ruz"] { --wash: url("/theme/art/wash-naw-ruz.png?v=68f17acd"); }
[data-theme="ridvan"] { --wash: url("/theme/art/wash-ridvan.png?v=68f17acd"); }
[data-theme="birth-bab"] { --wash: url("/theme/art/wash-birth-bab.png?v=68f17acd"); }
[data-theme="birth-bahaullah"] { --wash: url("/theme/art/wash-birth-bahaullah.png?v=68f17acd"); }
[data-theme="declaration-bab"] { --wash: url("/theme/art/wash-declaration-bab.png?v=68f17acd"); }
[data-theme="covenant"] { --wash: url("/theme/art/wash-covenant.png?v=68f17acd"); }
[data-theme="martyrdom-bab"] { --wash: url("/theme/art/wash-martyrdom-bab.png?v=68f17acd"); }
[data-theme="ascension-bahaullah"] { --wash: url("/theme/art/wash-ascension-bahaullah.png?v=68f17acd"); }
[data-theme="ascension-abdulbaha"] { --wash: url("/theme/art/wash-ascension-abdulbaha.png?v=68f17acd"); }

/* Naw-Ruz: spring green */
[data-theme="naw-ruz"] {
  --color-bg: #F6F7EC;
  --color-surface: #FCFDF6;
  --color-accent: #9BC25A;
  --color-accent-2: #E3B8A8;
  --color-primary: #3F6B3A;
  --color-border: #CFD3A6;
  --color-focus: #6E4E6B;
  --petal-1: #CFE3A0; --petal-2: #9BC25A; --petal-3: #E8B8C0; --petal-core: #3F6B3A; --petal-stroke: #3F6B3A; --petal-fall: #9BC25A;
}
/* Ridvan: rose garden */
[data-theme="ridvan"] {
  --color-bg: #FAF2EE;
  --color-surface: #FFFAF7;
  --color-accent: #E39A8F;
  --color-accent-2: #C9776B;
  --color-primary: #8A4A5A;
  --color-border: #E3BFB0;
  --petal-1: #F0C4BA; --petal-2: #E39A8F; --petal-3: #C9776B; --petal-core: #8A4A5A; --petal-stroke: #8A4A5A; --petal-fall: #E39A8F;
}
/* Birth of the Bab / Birth of Baha'u'llah: gold */
[data-theme="birth-bab"],
[data-theme="birth-bahaullah"] {
  --color-bg: #FAF5E6;
  --color-surface: #FFFCF2;
  --color-accent: #E0AE3E;
  --color-accent-2: #C9776B;
  --color-primary: #7A5210;
  --color-border: #E3CB8E;
  --petal-1: #F0D68A; --petal-2: #E0AE3E; --petal-3: #C98F2A; --petal-core: #7A5210; --petal-stroke: #7A5210; --petal-fall: #E0AE3E;
}
/* Declaration of the Bab: dawn, gold into plum */
[data-theme="declaration-bab"] {
  --color-bg: #F9F2EE;
  --color-surface: #FFFAF7;
  --color-accent: #E6B36A;
  --color-accent-2: #B8869F;
  --color-primary: #5B3F5A;
  --color-border: #E0C2B0;
  --color-focus: #5B3F5A;
  --choice-1: #5B3F5A; --choice-1-ink: #FBF5EA;
  --petal-1: #F0CFA0; --petal-2: #E6B36A; --petal-3: #B8869F; --petal-core: #5B3F5A; --petal-stroke: #5B3F5A; --petal-fall: #B8869F;
}
/* Day of the Covenant: sage and plum */
[data-theme="covenant"] {
  --color-bg: #F3F5EC;
  --color-surface: #FBFCF6;
  --color-accent: #B7CC8A;
  --color-accent-2: #8E6B8B;
  --color-primary: #4E5E32;
  --color-border: #C8CFA7;
  --color-focus: #5B3F5A;
  --petal-1: #CFDDB0; --petal-2: #B7CC8A; --petal-3: #8E6B8B; --petal-core: #4E5E32; --petal-stroke: #4E5E32; --petal-fall: #8E6B8B;
}

/* ================================================================
   13. REVERENT MODE  (muted umber; also used by the three
   martyrdom / ascension themes so they look right with or without
   the attribute). Must stay AFTER the theme blocks above so that
   data-reverent wins over any accent.
   ================================================================ */
[data-theme="martyrdom-bab"],
[data-theme="ascension-bahaullah"],
[data-theme="ascension-abdulbaha"],
[data-reverent="true"] {
  --color-bg: #ECE8E0;
  --color-surface: #F6F3EC;
  --color-ink: #3B2A1E;                 /* 11.19:1 on bg */
  --color-ink-soft: #5E4A3A;            /* 6.83:1 on bg */
  --color-accent: #A58B6B;
  --color-accent-2: #8C7767;
  --color-on-accent: #2E2016;
  --color-success: #4A5E34;
  --color-danger: #8C3A30;
  --color-primary: #5E4A3A;
  --color-on-primary: #F6F3EC;
  --color-border: #C9B9A3;
  --color-border-strong: #7A624D;
  --color-focus: #5B3F5A;
  --petal-1: #CDBBA3; --petal-2: #A58B6B; --petal-3: #8C7767; --petal-core: #5E4A3A; --petal-stroke: #5E4A3A; --petal-fall: #A58B6B;
  --choice-1: #5B4A5A; --choice-1-ink: #F6F3EC;
  --choice-2: #4F5A3E; --choice-2-ink: #F6F3EC;
  --choice-3: #6E4A42; --choice-3-ink: #F6F3EC;
  --choice-4: #B59B72; --choice-4-ink: #2E2016;
  --choice-5: #5E4A3A; --choice-5-ink: #F6F3EC;
  --choice-6: #46596A; --choice-6-ink: #F6F3EC;
  --vignette: rgba(59, 42, 30, 0.3);
  --flourish-opacity: 0.45;
  --shadow-soft: 0 2px 4px rgba(59, 42, 30, 0.14), 0 8px 18px -8px rgba(59, 42, 30, 0.3);
  --dur-fast: 300ms;
  --dur-med: 600ms;
  --dur-slow: 1400ms;
}
/* reverent: no drifting petals, no bursts (flower.js also no-ops), slower sway */
[data-theme="martyrdom-bab"] .drift,
[data-theme="ascension-bahaullah"] .drift,
[data-theme="ascension-abdulbaha"] .drift,
[data-reverent="true"] .drift { display: none; }
[data-reverent="true"] .burst-layer { display: none; }
[data-reverent="true"] .bob, [data-reverent="true"] .locked-in { animation-duration: 9s; }
[data-reverent="true"] .blossom--spin { animation-duration: 240s; }
[data-reverent="true"] .flourish img { animation-duration: 32s; }
/* art in reverent mode: desaturated, sepia-toned */
[data-reverent="true"] .flourish img, [data-reverent="true"] .blossom, [data-reverent="true"] .timer svg,
[data-theme="martyrdom-bab"] .flourish img, [data-theme="ascension-bahaullah"] .flourish img, [data-theme="ascension-abdulbaha"] .flourish img {
  filter: saturate(0.45) sepia(0.25) brightness(0.97);
}

/* ================================================================
   14. REDUCED MOTION
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .drift, .burst-layer { display: none !important; }
  .btn:hover, .btn:active, .choice:hover, .choice:active { transform: none; }
}

/* ================================================================
   15. STYLEGUIDE HELPERS (only used by /styleguide)
   ================================================================ */
.sg { max-width: 72rem; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-8); }
.sg section { margin-top: var(--space-7); }
.sg-bar { position: sticky; top: 0; z-index: 60; display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; padding: var(--space-3) var(--space-4); background: var(--color-surface); border-bottom: 2px solid var(--color-border); }
.sg-bar .input { width: auto; min-width: 14rem; }
.sg-toggle { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--touch); font-weight: 800; }
.sg-toggle input { width: 1.75rem; height: 1.75rem; accent-color: var(--color-primary); }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.sg-sw { display: flex; flex-direction: column; border: 2px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); font-size: var(--fs-small); }
.sg-sw__chip { height: 4.5rem; border-bottom: 2px solid var(--color-border); }
.sg-sw__meta { padding: var(--space-2) var(--space-3); line-height: 1.3; }
.sg-sw code, .sg code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
.sg-space { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.sg-space__bar { height: 1rem; background: var(--color-accent); border-radius: 2px; }
.sg-space--1 .sg-space__bar { width: var(--space-1); } .sg-space--2 .sg-space__bar { width: var(--space-2); }
.sg-space--3 .sg-space__bar { width: var(--space-3); } .sg-space--4 .sg-space__bar { width: var(--space-4); }
.sg-space--5 .sg-space__bar { width: var(--space-5); } .sg-space--6 .sg-space__bar { width: var(--space-6); }
.sg-space--7 .sg-space__bar { width: var(--space-7); } .sg-space--8 .sg-space__bar { width: var(--space-8); }
.sg-box { width: 7rem; height: 4.5rem; background: var(--color-surface); border: 2px solid var(--color-border-strong); box-shadow: var(--shadow-soft); }
.sg-box--sm { border-radius: var(--radius-sm); } .sg-box--md { border-radius: var(--radius-md); } .sg-box--lg { border-radius: var(--radius-lg); }
.sg-dur { display: inline-block; width: 3rem; height: 3rem; border-radius: 50%; background: var(--color-primary); }
.sg-dur--fast { transition: transform var(--dur-fast) var(--ease); }
.sg-dur--med { transition: transform var(--dur-med) var(--ease); }
.sg-dur--slow { transition: transform var(--dur-slow) var(--ease); }
.sg-dur-row:hover .sg-dur { transform: translateX(8rem); }
.sg-stage { position: relative; min-height: 14rem; display: grid; place-items: center; }
.sg-font-sample { font-size: 1.5rem; }
.sg-big-demo { border: 2px dashed var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); }
.sg-glyph-key { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.sg-col { max-width: 28rem; }
.sg-c-color-bg { background: var(--color-bg); }
.sg-c-color-surface { background: var(--color-surface); }
.sg-c-color-ink { background: var(--color-ink); }
.sg-c-color-ink-soft { background: var(--color-ink-soft); }
.sg-c-color-accent { background: var(--color-accent); }
.sg-c-color-accent-2 { background: var(--color-accent-2); }
.sg-c-color-success { background: var(--color-success); }
.sg-c-color-danger { background: var(--color-danger); }
.sg-c-color-primary { background: var(--color-primary); }
.sg-c-color-on-primary { background: var(--color-on-primary); }
.sg-c-color-border { background: var(--color-border); }
.sg-c-color-border-strong { background: var(--color-border-strong); }
.sg-c-choice-1 { background: var(--choice-1); }
.sg-c-choice-2 { background: var(--choice-2); }
.sg-c-choice-3 { background: var(--choice-3); }
.sg-c-choice-4 { background: var(--choice-4); }
.sg-c-choice-5 { background: var(--choice-5); }
.sg-c-choice-6 { background: var(--choice-6); }
.sg-c-parchment { background: var(--parchment); }
.sg-c-parchment-light { background: var(--parchment-light); }
.sg-c-sepia { background: var(--sepia); }
.sg-c-umber { background: var(--umber); }
.sg-c-sand { background: var(--sand); }
.sg-c-gold { background: var(--gold); }
.sg-c-rose { background: var(--rose); }
.sg-c-sage { background: var(--sage); }
.sg-c-plum { background: var(--plum); }
.sg-c-petal-1 { background: var(--petal-1); }
.sg-c-petal-2 { background: var(--petal-2); }
.sg-c-petal-3 { background: var(--petal-3); }
.sg-c-petal-core { background: var(--petal-core); }

/* ================================================================
   16. NAME PICKER (play page): generated names, no free text
   .name-card (+ __name, __badge), .shuffle-btn, .segmented > .segmented__opt[aria-pressed],
   .badge-grid > .badge[aria-pressed] (+ .badge--number)
   ================================================================ */
.name-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) 0;
  text-align: center;
  background: transparent;   /* sits directly on the page backdrop, like .card--deckle */
}
.name-card > * { max-width: 100%; }
.name-card .badge-grid, .name-card .segmented { width: 100%; }
.name-card__badge {
  display: grid;
  place-items: center;
  min-width: 5rem;
  min-height: 5rem;
  padding: 0 var(--space-3);
  border-radius: 50%;
  background: var(--color-bg);
  border: 3px solid var(--color-border);
  font: 800 2.75rem/1 var(--font-body);
  color: var(--color-ink);
  animation: chip-in var(--dur-slow) var(--ease) both;
}
.name-card__name {
  font-family: var(--font-display);
  font-variation-settings: var(--display-variation);
  font-weight: 700;
  font-size: clamp(1.75rem, 1rem + 4vw, 2.5rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
  color: var(--color-ink);
}
.shuffle-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-5);
  background: transparent;
  color: var(--color-ink);
  border: 2px dashed var(--color-border-strong);
  border-radius: 999px;
  font: 800 1.125rem/1 var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.shuffle-btn::before { content: "\21BB"; font-size: 1.4em; line-height: 1; }
.shuffle-btn:hover { background: var(--color-surface); }
.shuffle-btn:active { transform: scale(0.97); }
.segmented {
  display: flex;
  width: 100%;
  padding: 4px;
  gap: 4px;
  background: var(--color-bg);
  border: 2px solid var(--color-border-strong);
  border-radius: 999px;
}
.segmented__opt, .segmented__btn {
  appearance: none;
  flex: 1 1 0;
  min-height: calc(var(--touch) - 8px);
  padding: 0 var(--space-4);
  background: transparent;
  color: var(--color-ink);
  border: 0;
  border-radius: 999px;
  font: 800 1.0625rem/1.1 var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
}
.segmented__opt[aria-pressed="true"], .segmented__btn[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.5rem, 1fr)); gap: var(--space-2); max-height: 40vh; overflow-y: auto; padding: var(--space-1); }
.badge {
  appearance: none;
  display: grid;
  place-items: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font: 700 1.75rem/1 var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.badge:active { transform: scale(0.94); }
.badge[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); border-color: var(--color-ink); box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 6px var(--color-ink); }
.badge--number { font: 800 1.25rem/1 var(--font-display); font-variant-numeric: tabular-nums; }

/* ================================================================
   17. PRINTED-CORRESPONDENCE LANGUAGE (Edwardian illustrated greeting card)
   Hairline gilt rules, small ornaments, lightly textured ivory paper, negative space first.
   Nothing here implies mailing or postage: no stamps, postmarks, perforations or address lines.
   ================================================================ */
:root {
  --gilt: #B4832A;                 /* antique gold ink: decoration only, never text */
  --gilt-soft: #D8BC78;
  --card-stock: #FFFDF8;
  --halftone: radial-gradient(rgba(94, 58, 14, 0.05) 0.7px, transparent 0.9px);
  --emboss: inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -1px 0 rgba(74, 46, 26, 0.12);
  --orn-tl: url(/theme/art/ornament-corner.svg?v=68f17acd);      /* owner art, tinted with --gilt through mask-image */
  --orn-br: url(/theme/art/ornament-corner-br.svg?v=68f17acd);   /* same corner turned 180deg (masks cannot rotate) */
  --orn-rule: url(/theme/art/ornament-rule.svg?v=68f17acd);
  --orn-flourish: url(/theme/art/ornament-flourish.svg?v=68f17acd);
}
[data-reverent="true"], [data-theme="martyrdom-bab"], [data-theme="ascension-bahaullah"], [data-theme="ascension-abdulbaha"] {
  --gilt: #8F7A5C; --gilt-soft: #BBAA8E; --card-stock: #F1EEE7;
}
/* Optional hairline frame for any positioned box */
.hairline-frame { position: relative; }
.hairline-frame::before { content: ""; position: absolute; inset: var(--pc-inset, 0.5rem); border: 1px solid var(--gilt); border-radius: var(--pc-radius, 0.6rem); pointer-events: none; }
.hairline-frame::after { content: ""; position: absolute; inset: var(--pc-inset, 0.5rem); pointer-events: none;
  background: var(--gilt); -webkit-mask: var(--orn-tl) left top / var(--pc-orn, 2rem) no-repeat, var(--orn-br) right bottom / var(--pc-orn, 2rem) no-repeat; mask: var(--orn-tl) left top / var(--pc-orn, 2rem) no-repeat, var(--orn-br) right bottom / var(--pc-orn, 2rem) no-repeat; }
.ornament-rule, .ornament-flourish { display: block; margin: var(--space-3) auto; background: var(--gilt); -webkit-mask: var(--orn-rule) center / contain no-repeat; mask: var(--orn-rule) center / contain no-repeat; }
.ornament-rule { width: min(100%, 32rem); aspect-ratio: 16 / 1; }
.ornament-flourish { width: min(70%, 15rem); aspect-ratio: 3 / 1; -webkit-mask-image: var(--orn-flourish); mask-image: var(--orn-flourish); }
.rule-hair { border: 0; border-top: 1px solid var(--gilt-soft); margin: var(--space-3) 0; }
.small-caps { font-variant-caps: all-small-caps; letter-spacing: 0.12em; }

/* ---- Phones / tablets: a light hairline border, art only on the outer edge (orientation-aware) ---- */
body.page-play { --pc-margin: 0.55rem; --pc-pad: 1rem; --pc-orn: 3.2rem; height: 100vh; height: 100dvh; overflow: hidden; }
@media (orientation: landscape) { body.page-play { --pc-margin: 0.35rem; --pc-pad: 0.6rem; --pc-orn: 2.6rem; } }
body.page-play::before { content: none; }
body.page-play::after { content: ""; position: fixed; inset: var(--pc-margin); z-index: -1; pointer-events: none; border: 1px solid var(--gilt); border-radius: 0.9rem;
  background: var(--gilt); -webkit-mask: var(--orn-tl) left top / var(--pc-orn) no-repeat, var(--orn-br) right bottom / var(--pc-orn) no-repeat; mask: var(--orn-tl) left top / var(--pc-orn) no-repeat, var(--orn-br) right bottom / var(--pc-orn) no-repeat; }
body.page-play .decor-layer--fixed { inset: var(--pc-margin); border-radius: 0.9rem; z-index: -2; }
body.page-play .flourish { --fl: clamp(4.5rem, 22vw, 7.5rem); opacity: 0.85; }
body.page-play .flourish--tr, body.page-play .flourish--bl { display: none; }
body.page-play .drift { display: none; }
body.page-play #app { position: fixed; top: calc(var(--pc-margin) + 1.1rem); left: calc(var(--pc-margin) + 1.1rem); right: calc(var(--pc-margin) + 1.1rem); bottom: calc(var(--pc-margin) + 3.4rem); min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 0.2rem; }
body.page-play #app .screen, body.page-play #app .play-screen { min-height: 100%; padding: var(--pc-pad) 0 var(--space-4); overflow: visible; background: none; }
body.page-play #app .play-center { margin-left: auto; margin-right: auto; }
body.page-play .player-bar { left: calc(var(--pc-margin) + 0.9rem); right: calc(var(--pc-margin) + 0.9rem); bottom: calc(var(--pc-margin) + 0.3rem); min-height: 2.8rem; padding: 0.5rem 2.4rem; background: transparent; border-top: 1px solid var(--gilt-soft); border-radius: 0; box-shadow: none; z-index: 5; align-items: center; font-weight: 800; }
body.page-play .player-bar[hidden] { display: none; }

/* /kit on narrow screens only */
@media (max-width: 820px) {
  body.kit-page { height: 100vh; height: 100dvh; overflow: hidden; --pc-margin: 0.55rem; }
  body.kit-page::before { content: none; }
  body.kit-page::after { content: ""; position: fixed; inset: var(--pc-margin); z-index: -1; pointer-events: none; border: 1px solid var(--gilt); border-radius: 0.9rem;
    background: var(--gilt); -webkit-mask: var(--orn-tl) left top / 1.8rem no-repeat, var(--orn-br) right bottom / 1.8rem no-repeat; mask: var(--orn-tl) left top / 1.8rem no-repeat, var(--orn-br) right bottom / 1.8rem no-repeat; }
  body.kit-page main.kit { position: fixed; top: calc(var(--pc-margin) + 1.1rem); left: calc(var(--pc-margin) + 1.1rem); right: calc(var(--pc-margin) + 1.1rem); bottom: calc(var(--pc-margin) + 1.1rem); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 1.2rem 0.2rem 1rem; max-width: none; margin: 0; }
  body.kit-page .flourish { --fl: clamp(3.5rem, 18vw, 5.5rem); opacity: 0.75; }
  body.kit-page .kit-header { background: transparent; border: 0; box-shadow: none; padding: 0; }
}

/* ---- Answer reveal: unveil the printed plate (minimal fade in reverent mode; none under reduced motion) ---- */
@keyframes unveil { from { clip-path: inset(0 100% 0 0); opacity: 0.35; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.reveal-view .q-body, .reveal-view .reveal-banner { animation: unveil 1.1s var(--ease) backwards; }
[data-reverent="true"] .reveal-view .q-body, [data-reverent="true"] .reveal-view .reveal-banner { animation: fade-in 1.6s ease backwards; }

/* reverent / solemn: decoration reduced to a whisper */
[data-reverent="true"] .flourish, [data-theme="martyrdom-bab"] .flourish, [data-theme="ascension-bahaullah"] .flourish, [data-theme="ascension-abdulbaha"] .flourish { opacity: 0.4; }
[data-reverent="true"] .flourish--br { display: none; }

/* one number only: hide a separate numeric countdown whenever the petal timer rendered its own */
.timer-wrap:has(.timer__svg) .countdown { display: none; }

/* styleguide helpers for this section */
.sg-card { --pc-inset: 0.6rem; --pc-orn: 2.4rem; padding: var(--space-6); min-height: 12rem; }
.sg-c-walnut { background: var(--walnut); } .sg-c-soft-sepia { background: var(--soft-sepia); } .sg-c-olive { background: var(--olive); } .sg-c-terracotta { background: var(--terracotta); } .sg-c-ivory { background: var(--ivory); }
.sg-code { font-size: clamp(2.5rem, 8vw, 4.5rem); }
/* phone footer: long generated names wrap instead of truncating; score and rank may drop to a second row */
body.page-play .player-bar { flex-wrap: wrap; row-gap: 0.1rem; column-gap: 0.8rem; padding-top: 0.35rem; padding-bottom: 0.35rem; font-size: clamp(0.9rem, 3.7vw, 1.05rem); line-height: 1.2; justify-content: center; }
body.page-play .player-bar__name { flex: 1 1 9rem; min-width: 0; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; text-align: left; }
body.page-play .player-bar__score, body.page-play .player-bar__rank, body.page-play .player-bar__badge { flex: none; }
body.page-play #app { bottom: calc(var(--pc-margin) + 4.4rem); }

/* compact badge picker: 5 per row (9 flower emoji, numbers 0 to 19), >=44px targets, no horizontal overflow.
   `body .badge-grid` outranks any page-level grid rule. */
body .badge-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.4rem; max-height: none; overflow: visible; padding: 2px; width: 100%; }
body .badge { min-width: 0; min-height: 2.75rem; height: 3rem; font-size: 1.5rem; border-radius: 0.75rem; }
body .badge--number { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; font-variant-numeric: lining-nums tabular-nums; }
.name-card, .name-card > * { min-width: 0; max-width: 100%; }
