/* ============================================================
   Dog Deck — visual system
   Field guide meets game table: warm paper cards, dark ink,
   one recognizable color per game, semantic feedback that never
   depends on color alone. Source of truth:
   Dog-Deck-App-Brand-Guidelines.md (v1.0, Aug 2026).
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
  /* Core palette (light appearance) */
  --bg: #F4ECDC;                 /* warm paper ground, a step below Card Bone */
  --card: #FFF7E8;               /* Card Bone — every card surface */
  --well: #EDE3CE;               /* inset wells on paper */
  --mist: #E8EDF6;               /* Morning Mist — secondary surfaces */
  --ink: #18213A;                /* Midnight Ink — headings, primary action */
  --text: #2A3142;               /* Graphite — body text */
  --text-2: #57627A;             /* secondary text (Quiet Slate, darkened for AA) */
  --line: #E0D5BC;               /* warm hairline on paper */
  --cardline: #EBDFC6;           /* card edge */
  --accent: #4D6BFF;             /* Deck Cobalt — links, focus, selection tint */
  --accent-strong: #3B54E0;      /* cobalt deep enough for white/bone text */
  --on-accent: #FFF7E8;
  --btn: #18213A;                /* product-level primary action */
  --on-btn: #FFF7E8;
  --shadow: 0 8px 22px rgba(24, 33, 58, .10);
  --shadow-lg: 0 14px 34px rgba(24, 33, 58, .14);

  /* Semantic feedback — global, never confused with a mode accent */
  --ok: #2D8A5B;        --ok-fill: #256B47;   --on-ok: #FFFFFF;
  --warn: #C48816;      --warn-fill: #C48816; --on-warn: #18213A;
  --bad: #C94E4E;       --bad-fill: #B23F3F;  --on-bad: #FFFFFF;
  --dir: #5F6F89;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "New York", ui-serif, Georgia, "Times New Roman", serif;
}

/* Mode identities. --m = accent, --m-deep = text/fill companion (AA with bone),
   --m-tint = quiet field behind icons and hero cards. */
[data-mode="snuffle"] { --m: #55C2D3; --m-deep: #1E6E7C; --m-tint: #DFF3F6; }
[data-mode="daily"]   { --m: #F2C84B; --m-deep: #7A5D10; --m-tint: #FBEFC9; }
[data-mode="quiz"]    { --m: #6D7DFF; --m-deep: #3A49B8; --m-tint: #E4E8FF; }
[data-mode="look"]    { --m: #C58BDD; --m-deep: #7C4E92; --m-tint: #F2E4F8; }
[data-mode="drill"]   { --m: #F3A15F; --m-deep: #96541A; --m-tint: #FBE6D2; }
[data-mode="coll"]    { --m: #79C8A1; --m-deep: #2F7A57; --m-tint: #DFF2E8; }
[data-mode="hist"]    { --m: #8095C8; --m-deep: #46598C; --m-tint: #E5EAF5; }
[data-mode="pass"]    { --m: #7FBFA8; --m-deep: #2E6B58; --m-tint: #DDF0E9; }
[data-mode="quarter"] { --m: #E4907B; --m-deep: #9B4634; --m-tint: #FAE3DC; }

/* Dark appearance: deep warm night, tonal mode companions —
   not an inversion, and never white text slapped on light accents. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A30;
    --card: #1D2742;
    --well: #16203A;
    --mist: #232E4E;
    --ink: #FFF7E8;
    --text: #ECE7DA;
    --text-2: #A9B2C9;
    --line: #2C3654;
    --cardline: #2C3654;
    --accent: #8FA2FF;
    --accent-strong: #4D6BFF;
    --on-accent: #FFF7E8;
    --btn: #FFF7E8;
    --on-btn: #18213A;
    --shadow: 0 10px 26px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
    --ok: #58B588;  --warn: #E0A93E;  --bad: #E07070;  --dir: #8FA0BC;
  }
  :root:not([data-theme="light"]) [data-mode="snuffle"] { --m-tint: #14333C; --m-deep: #7FD2E0; }
  :root:not([data-theme="light"]) [data-mode="daily"]   { --m-tint: #3A3014; --m-deep: #F2C84B; }
  :root:not([data-theme="light"]) [data-mode="quiz"]    { --m-tint: #222A56; --m-deep: #98A5FF; }
  :root:not([data-theme="light"]) [data-mode="look"]    { --m-tint: #33203D; --m-deep: #D5A9E8; }
  :root:not([data-theme="light"]) [data-mode="drill"]   { --m-tint: #3C2712; --m-deep: #F3A15F; }
  :root:not([data-theme="light"]) [data-mode="coll"]    { --m-tint: #16332A; --m-deep: #8FD4B2; }
  :root:not([data-theme="light"]) [data-mode="hist"]    { --m-tint: #202A44; --m-deep: #9FB1DC; }
  /* Passport Lab and Quarter were added after this block and never got their dark
     companions, so --m-deep stayed at its light-theme value and every label
     printed in it fell to about 2.3:1 on the dark card. */
  :root:not([data-theme="light"]) [data-mode="pass"]    { --m-tint: #17332B; --m-deep: #96D3BC; }
  :root:not([data-theme="light"]) [data-mode="quarter"] { --m-tint: #3B211B; --m-deep: #EFA995; }
}

/* ---------- base ---------- */
[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.4;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button { font-family: inherit; }

.screen { display: none; max-width: 600px; margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); }
.screen.active { display: block; animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

h1 { font-family: var(--font-round); font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin-bottom: 4px; }
.sub { color: var(--text-2); font-size: 15px; margin-bottom: 20px; }

/* ---------- home: brand header ---------- */
.brandmark { display: flex; align-items: center; gap: 12px; margin: 4px 0 0; }
.brandsym { width: 46px; height: 46px; flex: none; display: block; }
.brandtext { font-family: var(--font-round); font-size: 27px; font-weight: 800; letter-spacing: .045em; color: var(--ink); }
.tagline { color: var(--text-2); font-size: 15px; margin: 6px 0 4px; }

.sechead { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em;
  color: var(--text-2); margin: 26px 0 10px; }
.homesec:first-of-type .sechead { margin-top: 20px; }

.cardrow { display: grid; gap: 14px; }

/* ---------- home: game cards ---------- */
.gamecard { position: relative; display: flex; flex-direction: column; align-items: stretch;
  background: var(--card); border: 1px solid var(--cardline); border-radius: 20px;
  padding: 18px; box-shadow: var(--shadow); overflow: hidden; }
.gamecard::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--m); }
.gamecard h3 { font-family: var(--font-round); font-size: 20px; font-weight: 800; letter-spacing: -.01em;
  color: var(--ink); margin: 10px 0 0; }
.modefield { width: 44px; height: 44px; border-radius: 12px; background: var(--m-tint); color: var(--m-deep);
  display: grid; place-items: center; }
.modefield svg { width: 24px; height: 24px; }
.modedesc { color: var(--text-2); font-size: 13.5px; line-height: 1.5; margin: 6px 0 14px; }
.gamecard .big { margin-top: auto; }

/* Daily heroes read louder than practice cards */
.gamecard.hero { background: linear-gradient(180deg, var(--m-tint) 0%, var(--card) 78%); padding: 20px 18px 18px; }
.gamecard.hero h3 { font-size: 24px; }
.gamecard.hero .modedesc { color: var(--text); opacity: .82; font-size: 14px; }
.gamecard.hero .modefield { background: var(--m); color: #18213A; }

/* Played-today chip: state you can't miss */
.chip { position: absolute; top: 14px; right: 14px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .04em; padding: 5px 10px; border-radius: 999px; }
.chip.played { background: var(--ok-fill); color: var(--on-ok); }
.chip.played::before { content: '✓ '; }
.gamecard.done .modefield { opacity: .75; }

/* Deck filters fold away — they shape the drill, they aren't a daily game */
.deckopts { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--well); }
.deckopts summary { cursor: pointer; padding: 11px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-2); list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.deckopts summary::-webkit-details-marker { display: none; }
.deckopts summary::after { content: '▾'; color: var(--text-2); transition: transform .15s ease; }
.deckopts[open] summary::after { transform: rotate(180deg); }
.deckopts .inner { padding: 2px 12px 12px; }
.deckcount { color: var(--text-2); font-size: 12.5px; margin-top: 10px; }

.publine { color: var(--text-2); font-size: 11.5px; text-align: center; letter-spacing: .06em;
  margin: 34px 0 8px; opacity: .85; }

/* ---------- shared controls ---------- */
.segs { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { flex: 1; min-width: 60px; min-height: 44px; padding: 10px 8px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--text); font-size: 14.5px; cursor: pointer;
  text-align: center; transition: transform .12s ease; }
.seg:active { transform: scale(.96); }
.seg.on { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); font-weight: 700; }

select { width: 100%; min-height: 44px; padding: 11px 34px 11px 12px; border-radius: 12px;
  background-color: var(--card); color: var(--text); border: 1px solid var(--line); font-size: 15px;
  font-family: inherit; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; }

.big { display: block; width: 100%; min-height: 52px; padding: 15px 16px; border: none; border-radius: 16px;
  font-family: var(--font-round); font-size: 17px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, filter .12s ease; }
a.big { display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; box-sizing: border-box; }
.crumb { display: inline-block; color: var(--text-2); font-size: 14px; font-weight: 600; text-decoration: none;
  padding: 8px 0; margin-bottom: 4px; border-radius: 6px; }
.crumb:hover { color: var(--accent); }
.big + .big { margin-top: 10px; }
.big:active { transform: scale(.98); filter: brightness(.94); }
.start { background: var(--btn); color: var(--on-btn); box-shadow: 0 5px 14px rgba(24, 33, 58, .18); }
[data-mode] .start { background: var(--m-deep); color: #FFF7E8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-mode] .start { background: var(--m-tint); color: var(--m-deep); border: 1px solid var(--m-deep); }
}
.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); margin-top: 10px; }

/* legacy result-color helpers */
.g { color: var(--ok); } .r { color: var(--text-2); }

/* ---------- card earned: the banner (Collection identity) ---------- */
/* Wider and taller than the pill it replaced, with the badge shown at the size
   it's actually legible — earning a card is the one thing the deck rewards, and
   it was announcing itself too quietly to notice mid-run. Still calm by house
   rule: one accent, no confetti, and pointer-transparent so it can never eat a
   tap while you're playing. */
.toast { position: fixed; top: calc(72px + env(safe-area-inset-top)); left: 50%; z-index: 20;
  width: min(460px, calc(100% - 24px)); transform: translate(-50%, -18px); opacity: 0;
  pointer-events: none; transition: opacity .24s ease, transform .24s ease;
  background: #2F7A57; border: 1px solid #79C8A1; border-radius: 18px;
  padding: 14px 18px; box-shadow: var(--shadow-lg); color: #FFF7E8;
  display: flex; align-items: center; gap: 14px; }
.toast .ttx { min-width: 0; }
.toast .tbadge { width: 64px; height: 64px; flex: none; object-fit: contain;
  background: rgba(255, 247, 232, .14); border-radius: 12px; padding: 2px; box-sizing: border-box; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast .tt { color: #C9EBDA; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; }
.toast .tb { font-size: 19px; font-weight: 700; margin-top: 4px; font-family: var(--font-round); line-height: 1.15; }
.toast .tc { color: #C9EBDA; font-size: 12.5px; margin-top: 3px; }

/* ---------- game screens: shared hud ---------- */
#quiz, #look, #drill { padding: calc(10px + env(safe-area-inset-top)) 12px 12px; display: none; flex-direction: column;
  height: 100vh; height: 100dvh; max-width: 600px; margin: 0 auto; }
#quiz.active, #look.active, #drill.active { display: flex; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 2px 10px; font-variant-numeric: tabular-nums; position: relative; }
[data-mode] .hud::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: 3px; height: 3px;
  border-radius: 3px; background: var(--m); }
.hudscore { color: var(--text-2); font-size: 15px; font-weight: 600; }
.hudscore b.g { color: var(--ok); } .hudscore b.r { color: var(--text-2); }
/* Quarter banks points rather than counting finds, so its HUD score carries a
   unit. The number keeps the shared .hudscore treatment; only the suffix is new. */
.qtptshud { display: inline-flex; align-items: baseline; gap: 3px; }
.qtptshud span { color: var(--text-2); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hud button { background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  min-height: 40px; padding: 6px 16px; color: var(--text-2); font-size: 14px; cursor: pointer; }

/* ---------- quiz (Name That Dog + Daily Five) ---------- */
.qcard { flex: none; aspect-ratio: 3 / 2; margin-top: 8px; border-radius: 20px; overflow: hidden;
  background: var(--card); border: 1px solid var(--cardline); box-shadow: var(--shadow); position: relative; }
/* Photo field. Every one of the 339 studio photos is landscape — 3:2 for most of
   them, 4:3 for the rest — and none is square. Forcing a square and cropping to
   fill takes a third off a 3:2 dog, which is its head and its tail. So: a 3:2
   box, contained, on a near-white field that matches the studio background the
   photos were shot on. Nothing is ever cut off, and the 4:3 ones sit in bands
   you cannot see. The field is a fixed colour rather than a token on purpose —
   the photos are white-backed in either appearance, and a dark card colour would
   frame them with a visible border. */
.qcard img { width: 100%; height: 100%; object-fit: contain; background: #FDFCF8; }
.qopts { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 14px;
  grid-auto-rows: minmax(68px, auto); align-content: start; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
.qopt { position: relative; padding: 10px 8px; border-radius: 14px; border: 1px solid var(--cardline);
  background: var(--card); color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer;
  min-height: 56px; box-shadow: var(--shadow); transition: transform .1s ease; }
.qopt:active { transform: scale(.97); }
.qopt.hit { background: var(--ok-fill); border-color: var(--ok-fill); color: var(--on-ok); }
.qopt.miss { background: var(--bad-fill); border-color: var(--bad-fill); color: var(--on-bad); }
.qopt.hit::after, .qopt.miss::after { position: absolute; top: 5px; right: 9px; font-size: 13px; font-weight: 800; }
.qopt.hit::after { content: '✓'; }
.qopt.miss::after { content: '✕'; }
.qopt.reveal { box-shadow: 0 0 0 3px var(--ok); }
.qopt:disabled { cursor: default; }
.streakpill { position: absolute; top: 12px; right: 12px; background: rgba(24, 33, 58, .85); color: #FFF7E8;
  font-weight: 700; font-size: 14px; padding: 6px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; }

/* ---------- lookalikes ---------- */
.lkask { text-align: center; font-size: 17px; color: var(--text-2); padding: 2px 0 10px; }
.lkask b { color: var(--ink); font-weight: 800; }
.lkpair { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.lkopt { position: relative; width: 100%; aspect-ratio: 3 / 2; min-width: 0; padding: 0; border: 3px solid transparent; border-radius: 18px;
  overflow: hidden; background: var(--card); box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s ease, border-color .18s ease; }
.lkopt:active { transform: scale(.985); }
.lkopt img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none;
  object-fit: contain; display: block; pointer-events: none; }
.lktag { position: absolute; top: 10px; left: 10px; background: rgba(24, 33, 58, .85); color: #FFF7E8;
  font-size: 13px; font-weight: 800; padding: 4px 11px; border-radius: 999px; }
.lkname { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px;
  background: linear-gradient(0deg, rgba(24, 33, 58, .94), rgba(24, 33, 58, 0)); color: #fff;
  font-size: 14px; font-weight: 700; text-align: left; }
/* Both image frames stay equal before and after the answer. */
#look { height: auto; min-height: 100vh; min-height: 100dvh; }
.lkscale { text-align: center; color: var(--text-2); font-size: 12px; font-weight: 600;
  letter-spacing: .02em; padding-bottom: 8px; }
.lkopt.hit { border-color: var(--ok); }
.lkopt.miss { border-color: var(--bad); }
.lkopt.other { border-color: var(--line); opacity: .68; }
.lkopt:disabled { cursor: default; }
.lktell { flex: none; margin-top: 12px; background: var(--card); color: var(--text);
  border: 1px solid var(--cardline); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); animation: rise .25s ease; }
.lkverdict { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 9px; }
.lkverdict.ok { color: var(--ok); } .lkverdict.ok::before { content: '✓ '; }
.lkverdict.no { color: var(--bad); } .lkverdict.no::before { content: '✕ '; }
.lkstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 11px; }
.lkstat { border: 1px solid var(--line); background: var(--well); border-radius: 10px; padding: 7px 9px; }
.lkstat b { display: block; font-size: 12.5px; line-height: 1.25; margin-bottom: 2px; color: var(--ink); font-family: var(--font-serif); }
.lkstat span { color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.lktell p { font-size: 14.5px; line-height: 1.5; }
.lktell p + p { margin-top: 8px; }
#look .big { flex: none; margin-top: 10px; margin-bottom: max(0px, env(safe-area-inset-bottom)); }

/* ---------- snuffle ---------- */
#mysWrap { position: relative; margin-bottom: 14px; }
#mysInput { width: 100%; min-height: 48px; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; font-family: inherit; }
#mysInput::placeholder { color: var(--text-2); }
#mysInput:focus { border-color: var(--accent); outline: none; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; z-index: 5; box-shadow: var(--shadow-lg); }
.suggest button { display: block; width: 100%; min-height: 44px; text-align: left; padding: 11px 14px; background: none;
  border: none; color: var(--text); font-size: 15px; font-family: inherit; cursor: pointer; }
.suggest button:hover, .suggest button:focus { background: var(--mist); }
.mysrow { margin-bottom: 12px; animation: rise .25s ease; }
.mysname { font-size: 13px; font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; gap: 8px; min-height: 32px; color: var(--ink); }
.mysthumb { width: 32px; height: 32px; flex: none; border-radius: 8px; object-fit: cover; background: var(--card); display: block; }
/* Column count comes from the row, not from the stylesheet. Saved boards from
   before the A–Z cell hold five cells and must still render as five columns —
   they are a record of a game already played, and stretching them to six would
   be rewriting history to match today's rules. */
.myscells { display: grid; grid-template-columns: repeat(var(--cells, 5), minmax(0, 1fr)); gap: 6px; }
.cell { border-radius: 9px; padding: 5px 2px; text-align: center; background: var(--well); border: 1px solid var(--line);
  min-height: 46px; display: flex; flex-direction: column; justify-content: center; gap: 1px; color: var(--text); }
.cell b { font-size: 11.5px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cell span { font-size: 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.cell.g { background: var(--ok-fill); border-color: var(--ok-fill); color: var(--on-ok); }
.cell.g span { color: rgba(255, 255, 255, .85); }
.cell.y { background: var(--warn-fill); border-color: var(--warn-fill); color: var(--on-warn); }
.cell.y span { color: rgba(24, 33, 58, .7); }
.known { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.kchip { background: var(--ok-fill); color: var(--on-ok); font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px; animation: rise .25s ease; }
.kchip.hint { background: var(--warn-fill); color: var(--on-warn); }
.mysbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 12px; }
.myslegend { flex: 1 1 220px; color: var(--text-2); font-size: 11px; line-height: 1.4; }
#mysHint { background: var(--card); border: 1px solid var(--line); color: var(--m-deep); border-radius: 999px;
  min-height: 40px; padding: 8px 14px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; }
#mysHint:disabled { opacity: .45; cursor: default; }
.mysbtns { display: flex; align-items: center; gap: 8px; flex: none; }
#mysGroups, #mysAll { background: transparent; border: 1px solid var(--line); color: var(--text-2); border-radius: 999px;
  min-height: 40px; padding: 8px 14px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; }
#mysGroups[aria-expanded="true"], #mysAll[aria-expanded="true"] { color: var(--m-deep); border-color: var(--m-deep); }
.groupref { max-height: 40vh; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--well); }
.refsec + .refsec { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.reftitle { color: var(--text-2); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 7px; }
.refgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 3px 16px; }
.refgrid.wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.refgrid div { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.refgrid b { color: var(--m-deep); font-weight: 700; margin-right: 7px; }
/* All dogs — the name index. Same well as the Reference panel, but a scrolling
   column of names, so the letter headers stick and the filter rides above them. */
.alldogs { max-height: 44vh; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 12px;
  padding: 0 14px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--well); }
.allhead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 12px 0 10px; background: var(--well); }
#mysAllFilter { flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 12px; font-family: inherit;
  font-size: 14px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.allcount { flex: none; color: var(--text-2); font-size: 11px; font-weight: 600; }
.alletter { position: sticky; top: 62px; z-index: 1; background: var(--well); color: var(--text-2);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  padding: 7px 0 4px; border-bottom: 1px solid var(--line); }
#mysAllRows { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1px 14px; }
.alletter { grid-column: 1 / -1; }
.allname { display: block; width: 100%; text-align: left; min-height: 32px; padding: 6px 8px; margin: 0;
  background: none; border: 0; border-radius: 8px; font-family: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.allname:hover, .allname:focus { background: var(--mist); }
.allname.used { color: var(--text-2); text-decoration: line-through; opacity: .6; cursor: default; }
.allname.used:hover, .allname.used:focus { background: none; }
.allempty { grid-column: 1 / -1; color: var(--text-2); font-size: 12px; padding: 6px 0; }
.mysreveal { text-align: center; }
.mysreveal img { width: 200px; border-radius: 14px; border: 5px solid var(--card); box-shadow: var(--shadow-lg); margin: 12px auto; display: block; }
.mysreveal h3 { font-family: var(--font-serif); font-size: 26px; margin-top: 4px; color: var(--ink); }
.mysmeta { color: var(--text-2); font-size: 13px; margin: 6px 0 14px; }

/* ---------- fluency drill ---------- */
#timer { font-size: 28px; font-weight: 800; font-family: var(--font-round); font-variant-numeric: tabular-nums; color: var(--ink); }
#timer.low { color: var(--bad); }
#card { flex: 1; position: relative; cursor: pointer; min-height: 0; perspective: 1200px; }
.flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .34s; }
.flip.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--cardline); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.face.rear { transform: rotateY(180deg); }
/* Natural photo color — no blend modes, no tints. Contain keeps the full outline. */
#card img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; background: #FDFCF8; }
.clue { padding: 28px 24px; display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 16px; color: var(--text); }
.clue .lbl { color: var(--text-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.clue .val { font-size: 19px; line-height: 1.35; font-weight: 500; }
.back { padding: 26px 24px; overflow-y: auto; height: 100%; color: var(--text); }
.back h3 { font-family: var(--font-serif); font-size: 28px; letter-spacing: -.01em; margin-bottom: 2px; color: var(--ink); }
.back .orig { color: var(--text-2); font-size: 14px; font-style: italic; margin-bottom: 14px; }
.fact { margin-bottom: 11px; font-size: 15px; line-height: 1.4; }
.fact span { color: var(--text-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; display: block; }
.fliphint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  color: #FFF7E8; background: rgba(24, 33, 58, .85); padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; pointer-events: none; }
.answerbtns { display: flex; gap: 10px; padding-top: 14px; padding-bottom: max(0px, env(safe-area-inset-bottom)); }
.answerbtns button { flex: 1; min-height: 56px; padding: 16px; border: none; border-radius: 16px; font-size: 20px;
  font-weight: 800; cursor: pointer; opacity: .35; pointer-events: none; transition: transform .1s ease; }
.answerbtns.ready button { opacity: 1; pointer-events: auto; }
.answerbtns button:active { transform: scale(.97); }
.wrong { background: var(--bad-fill); color: var(--on-bad); }
.right { background: var(--ok-fill); color: var(--on-ok); }

/* ---------- results / quiz done ---------- */
.panel { background: var(--card); border: 1px solid var(--cardline); border-radius: 18px; padding: 18px;
  margin-bottom: 14px; box-shadow: var(--shadow); }
.bignum { font-size: 60px; font-weight: 800; letter-spacing: -.02em; text-align: center; color: var(--m-deep, var(--ink));
  font-family: var(--font-round); font-variant-numeric: tabular-nums; }
.bignum small { font-size: 15px; color: var(--text-2); font-weight: 400; letter-spacing: 0; display: block; font-family: var(--font-sans); }
.statrow { display: flex; gap: 10px; margin: 16px 0 4px; }
.stat { flex: 1; background: var(--well); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat .n.g { color: var(--ok); }
.stat .l { color: var(--text-2); font-size: 12px; margin-top: 2px; }
button.stat { font-family: inherit; cursor: pointer; appearance: none; -webkit-appearance: none; min-height: 44px;
  transition: transform .12s ease, border-color .12s ease; }
button.stat:hover { border-color: var(--accent); }
button.stat:active { transform: scale(.97); }
button.stat .l::after { content: ' ›'; font-weight: 700; color: var(--accent); }

/* The running count in running prose — a link, styled as one, not a button. */
.countlink { background: none; border: none; padding: 0; font: inherit; color: var(--accent);
  font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.countlink:hover { color: var(--accent-strong); }
.pbpill { display: block; width: fit-content; margin: 0 auto 10px; background: var(--ink); color: var(--card);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; padding: 5px 14px; border-radius: 999px; }
.dgrid { font-size: 22px; letter-spacing: 2px; text-align: center; margin: 10px 0; word-break: break-all; }

/* ---------- history chart (Record Indigo) ---------- */
#chart { width: 100%; height: 180px; }
.chgrid { stroke: var(--line); stroke-width: 1; }
.chlbl { fill: var(--text-2); font-size: 10px; font-family: var(--font-sans); }
.chline { fill: none; stroke: #8095C8; stroke-width: 2.5; }
.chdot { fill: var(--hist-dot, #46598C); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hist-dot: #C3CFE8; } }
.histnote { color: var(--text-2); font-size: 13px; text-align: center; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- collection: the album ---------- */
.cprog { height: 10px; background: var(--well); border-radius: 999px; overflow: hidden; margin: 8px 0 18px; border: 1px solid var(--line); }
.cprog i { display: block; height: 100%; background: linear-gradient(90deg, #79C8A1, #2F7A57); border-radius: 999px; transition: width .4s ease; }
.cgroup { color: var(--text-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; margin: 22px 0 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.cgroup .cn { float: right; font-weight: 600; letter-spacing: .04em; text-transform: none; opacity: .8; font-variant-numeric: tabular-nums; }
/* Every row is one height. Tiles used to size themselves — a collected card came
   out 104 px (square badge plus a name) and an uncollected one 82 px (a square
   and nothing else), so any row holding both sat ragged, with the badges riding
   high and their names stranded beside the neighbouring squares. `1fr` rows plus
   the default stretch alignment give every tile the tallest tile's height, and
   the internals lay themselves out inside it. */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px;
  grid-auto-rows: 1fr; }
.tile { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--cardline);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
/* The square that holds the art — or the "?", or an uncollected name. Keeping one
   media box for all three states is what keeps the grid regular. */
.tmedia { flex: 1 1 auto; min-height: 0; aspect-ratio: 1; display: flex; align-items: center;
  justify-content: center; overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Chibi badge tile. The photo crops to fill on purpose; a badge must not —
   cut-out art with its ears sliced off is a bug, so it's contained on a tinted
   field that reads as "earned" next to the paper-white photo tiles. */
.tile.badge { background: var(--mist); cursor: pointer; }
.tile.badge:hover { border-color: var(--accent); }
.tile.badge img { object-fit: contain; padding: 5px; box-sizing: border-box; }
/* Two lines, then ellipsis. A registry lens prints longer names than the deck's
   own — "Manchester Terrier (Standard)" — and one clipped line reads as breakage.
   The strip is always two lines tall so collected tiles all match each other. */
.tile .tn { flex: none; font-size: 9.5px; font-weight: 600; line-height: 1.25; padding: 4px 4px 5px;
  color: var(--text); text-align: center; min-height: calc(2 * 1.25em);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile.un { color: var(--text-2); font-size: 20px; font-weight: 700; background: transparent;
  border: 1.5px dashed var(--line); box-shadow: none; opacity: .8; }
.tile.txt { display: flex; align-items: center; justify-content: center; padding: 4px; text-align: center; font-size: 10px; font-weight: 600; color: var(--text); }
.tile.name { background: transparent; border: 1.5px dashed var(--line); box-shadow: none; }
.tile.name .tmedia { padding: 4px; text-align: center; font-size: 10px; font-weight: 600;
  line-height: 1.2; color: var(--text-2); overflow: hidden; }
.collctl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 14px 0 16px; }
.collctl .segs { flex: 1 1 260px; }
.ctllabel { color: var(--text-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); font-size: 13px;
  -webkit-user-select: none; user-select: none; min-height: 44px; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.swt { flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--well); border: 1px solid var(--line);
  position: relative; transition: background .15s ease, border-color .15s ease; }
.swt::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--text-2); transition: transform .15s ease, background .15s ease; }
.sw input:checked + .swt { background: var(--accent-strong); border-color: var(--accent-strong); }
.sw input:checked + .swt::after { transform: translateX(18px); background: #FFF7E8; }
.sw input:focus-visible + .swt { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Home mini progress for the deck */
.miniprog { height: 8px; background: var(--well); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 2px 0 14px; }
.miniprog i { display: block; height: 100%; background: linear-gradient(90deg, #79C8A1, #2F7A57); border-radius: 999px; transition: width .4s ease; }

/* ---------- badge sheet: the art index (badges.html) ---------- */
/* A review instrument, not a game screen. The field toggle is the point: a badge
   has to read on the Collection's mist tile, on paper, on the dark ground, and
   the checker exposes a white background pretending to be transparency. */
#badges { max-width: 1100px; }
.bsctl { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 14px; }
.bsrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bsrow .ctllabel { flex: none; width: 84px; white-space: nowrap; }
.bsrow .segs { flex: 1 1 240px; max-width: 520px; }
#bsSearch { width: 100%; min-height: 48px; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; font-family: inherit; -webkit-appearance: none; appearance: none; }
#bsSearch::placeholder { color: var(--text-2); }
#bsSearch:focus { border-color: var(--accent); outline: none; }

/* On a phone the row label and four field buttons can't share a line without
   clipping the last one, so the label sits above its buttons instead. */
@media (max-width: 540px) {
  .bsrow { flex-direction: column; align-items: stretch; gap: 6px; }
  .bsrow .ctllabel { width: auto; }
  /* flex:1 1 240px means 240px *tall* once the row turns into a column. */
  .bsrow .segs { flex: 0 0 auto; max-width: none; }
}

.bsgrid { display: grid; gap: 8px; margin-bottom: 4px;
  grid-template-columns: repeat(auto-fill, minmax(var(--bs-px, 76px), 1fr)); }
.bstile { margin: 0; border: 1px solid var(--cardline); border-radius: 12px; overflow: hidden;
  background: var(--card); box-shadow: var(--shadow); cursor: zoom-in; }
.bstile img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; padding: 5px; box-sizing: border-box; }
.bstile figcaption { font-size: 9.5px; font-weight: 600; padding: 4px 4px 5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; background: var(--card); }

/* The four grounds. Dark and checker are fixed colors, not tokens — they have to
   look the same whichever appearance the reviewer's machine is in, or the test
   isn't a test. */
#badges[data-field="mist"] .bstile img { background: var(--mist); }
#badges[data-field="paper"] .bstile img { background: var(--card); }
#badges[data-field="dark"] .bstile img { background: #1D2742; }
#badges[data-field="check"] .bstile img {
  background-color: #FFFFFF;
  background-image: linear-gradient(45deg, #C8CEDA 25%, transparent 25%, transparent 75%, #C8CEDA 75%),
                    linear-gradient(45deg, #C8CEDA 25%, transparent 25%, transparent 75%, #C8CEDA 75%);
  background-size: 14px 14px; background-position: 0 0, 7px 7px; }

.bsgap { border: 1px solid var(--warn); border-left-width: 4px; border-radius: 10px; background: var(--card);
  padding: 10px 12px; margin: 10px 0 4px; font-size: 13px; color: var(--text); line-height: 1.5; }
.bsempty { color: var(--text-2); text-align: center; padding: 40px 0; }

/* Badge lightbox — used by badges.html only. The Collection's own badge
   lightbox was replaced by the full subject-and-passport view. */
.bslight { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(24, 33, 58, .72); cursor: zoom-out; }
.bslight figure { margin: 0; text-align: center; max-width: min(520px, 100%); }
.bslight img { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 18px;
  background: var(--mist); }
#badges[data-field="mist"] ~ .bslight img { background: var(--mist); }
#badges[data-field="paper"] ~ .bslight img { background: var(--card); }
#badges[data-field="dark"] ~ .bslight img { background: #1D2742; }
#badges[data-field="check"] ~ .bslight img {
  background-color: #FFFFFF;
  background-image: linear-gradient(45deg, #C8CEDA 25%, transparent 25%, transparent 75%, #C8CEDA 75%),
                    linear-gradient(45deg, #C8CEDA 25%, transparent 25%, transparent 75%, #C8CEDA 75%);
  background-size: 22px 22px; background-position: 0 0, 11px 11px; }
.bslight figcaption { margin-top: 12px; color: #FFF7E8; font-family: var(--font-round); font-size: 17px; font-weight: 700; }
.bslight code { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 400; opacity: .75; }

/* ---------- responsive: tablet and desktop ---------- */
@media (min-width: 760px) {
  .lkpair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #home { max-width: 1020px; padding-left: 28px; padding-right: 28px; }
  .cardrow.today { grid-template-columns: 1.35fr 1fr; align-items: stretch; }
  .cardrow.practice { grid-template-columns: repeat(3, 1fr); align-items: stretch; }
  .cardrow.deckrow { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .brandsym { width: 54px; height: 54px; }
  .brandtext { font-size: 32px; }
  #quiz, #look, #drill { max-width: 640px; }
  .screen:not(#home):not(#collection):not(#badges):not(#library):not(#libraryDetail):not(#mystery) { max-width: 640px; }
  #collection { max-width: 1020px; padding-left: 28px; padding-right: 28px; }
  #badges { padding-left: 28px; padding-right: 28px; }
  #collection .cgrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  #collection .collctl .segs { flex: 0 1 460px; }
}
@media (min-width: 1200px) {
  #home { max-width: 1120px; }
}
/* Short viewports: keep answers reachable, shrink chrome not controls */
@media (max-height: 640px) {
  .qcard { aspect-ratio: auto; flex: 1 1 40%; min-height: 120px; }
  .qopts { flex: 1 1 52%; grid-auto-rows: minmax(56px, auto); }
  .hud { padding-bottom: 6px; }
}


/* ---------- registry passport ---------- */
/* Recognition is never carried by colour alone: each stamp holds its registry's
   letter and a filled / half / hollow mark, and the whole strip has one spoken
   label. A status is never printed beside a group as though it were one. */
.passport { margin: 12px 0 4px; }
.pstamps { display: flex; gap: 7px; margin-bottom: 9px; }
.pstamp { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 3px 9px;
  border-radius: 999px; border: 1.5px solid var(--line); background: transparent;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--text-2); }
.pstamp i { font-style: normal; font-size: 10px; }
.pstamp.full { border-color: var(--ink); background: var(--ink); color: var(--card); }
.pstamp.listed { border-color: var(--ink); color: var(--ink); border-style: dashed; }
.pstamp.none { color: var(--text-2); border-style: dotted; border-color: var(--text-2); }
.prows { display: flex; flex-direction: column; gap: 6px; }
.prow { display: grid; grid-template-columns: 34px minmax(0, 1.35fr) minmax(0, 1fr); gap: 4px 10px;
  align-items: baseline; padding: 8px 10px; border-radius: 11px; background: var(--mist);
  border: 1px solid var(--cardline); font-size: 13px; }
.prow.none { grid-template-columns: 34px 1fr; background: transparent; border-style: dashed; color: var(--text-2); }
.preg { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; color: var(--text-2); }
.pname { font-weight: 700; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.pstd { font-style: normal; font-weight: 600; font-size: 11px; color: var(--text-2); margin-left: 5px; }
.pgroup { font-size: 12px; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
/* A listing with no true group says so in words, and is set apart from the ones
   that have one — it must never read as another group in the same list. */
.pgroup.nogroup { font-style: italic; color: var(--text-2); }
.pstatus { grid-column: 2 / -1; font-size: 11.5px; color: var(--text-2); }
.pdetail { margin-top: 8px; }
.pdetail summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--accent);
  min-height: 32px; display: flex; align-items: center; }
.pdetail ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.pdetail li { margin-bottom: 5px; overflow-wrap: anywhere; }
.pdetail li.pnote { color: var(--text); }

/* ---------- collection: lenses ---------- */
.segs.lens { flex: 1 1 100%; }
.lensnote { flex: 1 1 100%; font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin: -2px 0 2px; }
/* These two headings carry the most important honesty strings in the lens —
   "not yet assigned to an AKC group", "Not listed by the UKC". They keep the
   body-secondary colour every other heading uses, so they read at the same
   contrast; the dashed rule and the warn-coloured marker are decoration on top,
   never the message itself. */
.cgroup.status, .cgroup.none { color: var(--text-2); }
.cgroup.status { border-bottom-style: dashed; border-bottom-color: var(--warn); }
.cgroup.status::before { content: ''; display: inline-block; width: 8px; height: 8px;
  margin-right: 7px; border-radius: 2px; background: var(--warn); vertical-align: baseline; }
.cgroup.none { border-bottom-style: dotted; }
.cgroup.none::before { content: ''; display: inline-block; width: 8px; height: 8px;
  margin-right: 7px; border-radius: 2px; border: 1.5px dotted var(--text-2); vertical-align: baseline; }
.tile.got { cursor: pointer; }
.tile.got:hover, .tile.got:focus-visible { border-color: var(--accent); }
.tile { position: relative; }
.tplus { position: absolute; top: 3px; right: 3px; width: 15px; height: 15px; border-radius: 999px;
  background: var(--ink); color: var(--card); font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Watching the deck re-sort is the point of the lens control, so the grid settles
   rather than snapping. Subtle by house rule, and off entirely for reduced motion. */
.cgrid { animation: none; }
.resort .cgrid { animation: settle .34s ease; }
@keyframes settle { from { opacity: .35; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- a collected dog, opened ---------- */
.sjhead { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.sjbadge { width: 108px; height: 108px; object-fit: contain; background: var(--mist);
  border: 1px solid var(--cardline); border-radius: 16px; padding: 5px; box-sizing: border-box; flex: none; }
.sjhead h1 { margin: 0 0 2px; font-size: 21px; line-height: 1.2; }
.sjorig { color: var(--text-2); font-size: 13px; margin-bottom: 8px; }
.sjseals { display: flex; flex-wrap: wrap; gap: 6px; }
.seal { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); }
.seal.on { border-color: var(--ok); color: var(--ok); }
.seal i { font-style: normal; font-weight: 800; }
.sjfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-bottom: 4px; }
.sjfacts > div { background: var(--card); border: 1px solid var(--cardline); border-radius: 12px; padding: 9px 11px; }
.sjfacts b { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 3px; }
.sjfacts span { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.sjp { font-size: 14px; line-height: 1.6; color: var(--text); margin: 12px 0 0; }
.sjp b { color: var(--text-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-right: 5px; }

/* ---------- quarter ---------- */
/* The field count is the whole game, so it is the biggest thing on the screen and
   the bar under it shrinks with the deck. */
.qtfield { text-align: center; margin: 6px 0 14px; }
.qtcount { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.qtcount b { font-family: var(--font-round); font-size: 42px; font-weight: 800; color: var(--m-deep);
  line-height: 1; font-variant-numeric: tabular-nums; }
.qtcount span { font-size: 13px; color: var(--text-2); }
.qtbar { height: 8px; background: var(--well); border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; margin: 10px auto 8px; max-width: 420px; }
.qtbar i { display: block; height: 100%; background: var(--m); border-radius: 999px;
  transition: width .45s cubic-bezier(.4, 0, .2, 1); }
.qtasks { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }

/* A question needs a payoff, not just a new field count. This strip says what
   answered, how much ground disappeared, and whether the choice itself was
   strategically strong. No is neutral; only a wrong breed call is red. */
.qtpulse { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 11px;
  padding: 11px 12px; margin: 0 0 12px; border: 1px solid var(--cardline); border-left: 4px solid var(--m);
  border-radius: 13px; background: var(--card); box-shadow: var(--shadow); }
.qtpulse.pop { animation: qtpop .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes qtpop { from { opacity: .25; transform: translateY(-5px) scale(.99); } }
.qtpulse b { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px;
  color: var(--on-ok); background: var(--ok-fill); font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; white-space: nowrap; }
.qtpulse.answer b.no { background: var(--ink); color: var(--card); }
.qtpulse.guess { border-left-color: var(--bad); }
.qtpulse.guess b { background: var(--bad-fill); color: var(--on-bad); }
.qtpulse span { min-width: 0; font-size: 13px; color: var(--text); }
.qtpulse span strong { font-weight: 750; }
.qtpulse em { font-style: normal; color: var(--m-deep); font-size: 11px; font-weight: 800; white-space: nowrap; }

.qtknown { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
/* A ruled-out answer is struck through, not just recoloured — the ✓ / ✕ leads. */
.kchip.no { background: var(--well); color: var(--text-2); text-decoration: line-through;
  text-decoration-thickness: 1px; }
.qtturn { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 17px 0 9px; }
.qtturn b { color: var(--ink); font-family: var(--font-round); font-size: 17px; }
.qtturn span { max-width: 330px; color: var(--text-2); font-size: 11.5px; text-align: right; line-height: 1.35; }
.qtfeatured { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.qtgroup { margin-bottom: 12px; }
.qtcat { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px; }
.qtrow { display: flex; flex-wrap: wrap; gap: 7px; }
.qtq { min-height: 40px; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--cardline);
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease; }
.qtq:hover { border-color: var(--m-deep); }
.qtq:active { transform: scale(.96); }
.qtq.featured { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: 104px;
  padding: 11px 12px 10px; border-radius: 15px; text-align: left; }
.qtq.featured:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.qtqcat { color: var(--m-deep); font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.qtqlabel { display: block; color: var(--ink); font-size: 14px; font-weight: 750; line-height: 1.25; }
.qtq.featured .qtqlabel { margin: 3px 0 auto; font-size: 15px; }
.qtsplit { display: block; width: 100%; height: 5px; margin: 8px 0 5px; overflow: hidden;
  border-radius: 999px; background: var(--well); border: 1px solid var(--line); }
.qtsplit i { display: block; height: 100%; background: var(--m); border-right: 1px solid var(--m-deep); }
.qtodds { display: block; color: var(--text-2); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; }
.qtrow .qtq { display: grid; grid-template-columns: 58px auto; align-items: center; gap: 2px 8px; border-radius: 12px;
  min-height: 52px; text-align: left; }
.qtrow .qtqlabel { grid-column: 1 / -1; font-size: 12.5px; }
.qtrow .qtsplit { grid-column: 1; margin: 2px 0 0; }
.qtrow .qtodds { grid-column: 2; margin-top: 2px; }
.qtmore { margin-top: 11px; border: 1px solid var(--cardline); border-radius: 13px; background: var(--card); }
.qtmore summary { min-height: 44px; padding: 12px 14px; color: var(--text-2); font-size: 12px; font-weight: 750;
  cursor: pointer; list-style-position: inside; }
.qtmore[open] summary { color: var(--m-deep); border-bottom: 1px solid var(--cardline); }
.qtmorebody { padding: 13px 13px 2px; }
.qtnamewrap { background: var(--m-tint); border: 1px solid var(--cardline); border-radius: 16px;
  padding: 13px 14px; margin-bottom: 16px; }
.qtnamehead { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap;
  font-size: 13.5px; font-weight: 700; color: var(--m-deep); margin-bottom: 9px; }
.qtstake { flex: none; padding: 4px 9px; border-radius: 999px; background: var(--m-deep); color: var(--on-accent);
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em; }
.qtnames { display: flex; flex-wrap: wrap; gap: 7px; }
.qtname { min-height: 40px; padding: 8px 13px; border-radius: 10px; border: 1px solid var(--m-deep);
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: transform .12s ease; }
.qtname:hover { background: var(--m); color: var(--on-accent); }
.qtname:active { transform: scale(.96); }
.qtreveal { text-align: center; background: var(--card); border: 1px solid var(--cardline);
  border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.qtreveal h3 { font-family: var(--font-serif); font-size: 23px; margin: 12px 0 2px; }
.qtreveal .passport { text-align: left; }
.qtround { display: flex; align-items: baseline; justify-content: center; gap: 5px 8px; flex-wrap: wrap;
  padding: 9px 10px; margin: 10px auto 14px; border-radius: 11px; background: var(--m-tint); color: var(--m-deep);
  font-size: 12.5px; font-weight: 700; }
.qtround b { font-family: var(--font-round); font-size: 21px; line-height: 1; }
.qtround span { padding-left: 9px; border-left: 1px solid var(--m); }
/* Hero photos size themselves. The library is mixed 3:2 and 4:3, so a fixed box
   would band the 4:3 ones against their own studio ground however the field is
   coloured. A single large image has nothing to line up with, so it can simply
   be its own shape: no crop, no bands. */
.qtphoto { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto;
  border-radius: 16px; border: 1px solid var(--cardline); }

@media (max-width: 540px) {
  .qtpulse { grid-template-columns: auto minmax(0, 1fr); }
  .qtpulse em { grid-column: 2; margin-top: -5px; }
  .qtturn { display: block; }
  .qtturn span { display: block; margin-top: 2px; text-align: left; }
  .qtfeatured { grid-template-columns: 1fr; }
  .qtq.featured { min-height: 92px; }
  .qtnamehead { align-items: flex-start; }
}

/* ---------- snuffle history ---------- */
/* Wordle's stats block, in the deck's own furniture: the four numbers reuse the
   result screen's .statrow, and the distribution is a plain bar list so it stays
   readable at 320 px and under forced colors. */
.mysstats { margin: 14px 0 4px; text-align: left; }
.mysstats .statrow { margin-bottom: 14px; }
.distlab { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 7px; }
.dist { display: flex; flex-direction: column; gap: 4px; }
.distrow { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.distrow b { flex: none; width: 12px; font-size: 12px; font-weight: 700; color: var(--text-2); text-align: right; }
.distrow i { font-style: normal; font-size: 11px; font-weight: 700; line-height: 20px; min-height: 20px;
  padding: 0 7px; border-radius: 6px; background: var(--well); color: var(--text-2);
  box-sizing: border-box; text-align: right; transition: width .35s ease; }
/* The bar for today's answer, so a finished run finds itself in the history. */
.distrow.on i { background: var(--ok-fill); color: var(--on-ok); }
.distfoot { margin-top: 8px; font-size: 12px; color: var(--text-2); }

.mysfoot { margin-top: 10px; font-size: 12.5px; }
.histfix { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--card);
  border: 1px dashed var(--warn); }
.histfix p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: var(--text); }
.histempty { color: var(--text-2); font-size: 14px; line-height: 1.6; background: var(--card);
  border: 1px dashed var(--cardline); border-radius: 14px; padding: 16px 18px; }
#snufhist .mysstats { text-align: left; }

/* ---------- passport lab ---------- */
.psask { font-size: 17px; font-weight: 600; text-align: center; margin: 10px 0 12px; line-height: 1.35; }
.psask b { font-weight: 800; }
/* A column, not two centred inline boxes. The photo and its source pill are both
   inline-level, so on any viewport wider than the two of them together they used
   to sit side by side — the dog on the left, its registry pill stranded out to
   the right — while on a phone they stacked and looked fine. */
.pscard { display: flex; flex-direction: column; align-items: center; }
.pscard img { width: 100%; max-width: 380px; height: auto; display: block;
  border-radius: 18px; border: 1px solid var(--cardline); box-shadow: var(--shadow); }
.pssrc { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 9px;
  margin: 10px 0 0; padding: 7px 13px; border-radius: 999px; background: var(--mist);
  border: 1px solid var(--cardline); font-size: 13px; max-width: 100%; }
.pssrc .pslabel { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; color: var(--text-2); }
.pssrc span:not(.pslabel) { color: var(--text-2); font-size: 12.5px; }
.psreveal { margin-top: 14px; background: var(--card); border: 1px solid var(--cardline);
  border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.pswhat { font-size: 13.5px; line-height: 1.55; color: var(--text); margin: 0; }
#passport .qopts { flex: none; min-height: 0; padding-top: 12px; }
/* Search suggestions the deck knows by name but has no card for. Honest rather
   than hidden: the name resolves, and the row says why it can't be guessed. */
.suggest button.nodeck { color: var(--text-2); font-style: italic; cursor: default; opacity: .75; }
.suggest button.nodeck:hover { background: none; }

/* ---------- motion, contrast, forced colors ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen.active, .mysrow, .kchip, .lktell, .qtpulse { animation: none; }
  .resort .cgrid { animation: none; }
  .flip { transition: none; }
  .seg, .big, .qopt, .lkopt, .answerbtns button { transition: none; }
  .toast { transition: opacity .22s ease; }
  .cprog i, .miniprog i, .distrow i, .qtbar i { transition: none; }
  .qtq, .qtname { transition: none; }
  .deckopts summary::after { transition: none; }
}
@media (prefers-contrast: more) {
  :root { --line: #B9AC8C; --cardline: #B9AC8C; --text-2: #414B60; }
  .gamecard, .panel, .qopt, .lkopt, .tile, .prow, .pstamp, .qtq, .qtname { border-width: 2px; }
}
/* The dark palette declares these tokens on `:root:not([data-theme="light"])`,
   which outranks a bare `:root` however late it appears — so the block above was
   silently doing nothing in dark mode. Mirrored here at matching specificity,
   with values lightened for the dark ground rather than copied from the light one. */
@media (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root:not([data-theme="light"]) { --line: #4A587C; --cardline: #4A587C; --text-2: #C7CFE2; }
}
@media (prefers-contrast: more) {
  :root[data-theme="dark"] { --line: #4A587C; --cardline: #4A587C; --text-2: #C7CFE2; }
}
@media (forced-colors: active) {
  .gamecard, .panel, .qopt, .lkopt, .tile, .toast, .cell, .seg, .big,
  .prow, .pstamp, .sjfacts > div, .psreveal, .pssrc, .qtpulse, .qtround { box-shadow: none; border: 1px solid CanvasText; }
  .gamecard::before, .hud::after { background: CanvasText; }
  /* Every colour we set is discarded here, and green/amber/blank are the whole
     Snuffle grid. Four of the five cells print the guess's own value whatever the
     outcome, so without a mark a match and a miss are the same picture. */
  .cell.g b::after { content: ' \2713'; }
  .cell.y b::after { content: ' \223C'; }
  .cell.g { border-width: 3px; }
  .cell.y { border-style: dashed; border-width: 2px; }
  /* Same for the registry stamps and the correct/wrong answer buttons. */
  .pstamp.full { border-width: 3px; }
  .pstamp.listed { border-style: dashed; border-width: 2px; }
  .pstamp.none { border-style: dotted; }
  .distrow.on i { border: 2px solid CanvasText; }
  .qopt.hit { border-width: 3px; }
  .qopt.miss { border-style: dashed; border-width: 2px; }
}
/* prefers-contrast asks for more separation, not a different code path: the same
   marks help there, where amber on paper is the weakest pair in the grid. */
@media (prefers-contrast: more) {
  .cell.g b::after { content: ' \2713'; }
  .cell.y b::after { content: ' \223C'; }
}
