/* ---------- ✨ Glow-up: the Ink Pop look for the rest of the app ----------
   Home (css/home.css), Write it! (css/write.css), the word picker (css/picker.css) and the Game Lab
   share one look: Lilita One headings, Nunito body, ink outlines with hard offset shadows, 田字格 paper.
   This file brings Word sets, the Leaderboard, the Brain Garden, Dictation and the plain sheets
   (word card, part card, ☁️ Family account, grown-ups check) into it. Everything is scoped to those
   screens and sheets, so the Parent dashboard (Living Paper), onboarding, Fight the Brainrot and the
   kid switcher keep their own styles. */
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) {
  --ink: #1d2233;
  --muted: #6b6578;
  --line: #e7e1d6;
  --paper: #fdfbf7;
  --pop-pink: #ff3d7f; --pop-cyan: #19b6d6; --pop-yellow: #ffc22e; --pop-violet: #7a5cff; --pop-green: #2ec27e; --pop-coral: #ff7a59;
  --green: #2ec27e;
  --accent: #ff5a4e;
  --f-display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --f-body: "Nunito", -apple-system, "PingFang SC", "Segoe UI", system-ui, sans-serif;
  --f-brush: "Ma Shan Zheng", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --hard: 0 4px 0 var(--ink);
  font-family: var(--f-body);
  color: var(--ink);
}
:is(#sets, #leaderboard, #progress, #dictation) {
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(220, 70, 70, .08) 2px, transparent 2px), linear-gradient(90deg, rgba(220, 70, 70, .08) 2px, transparent 2px),
    linear-gradient(rgba(220, 70, 70, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(220, 70, 70, .045) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 60px 60px, 60px 60px;
  background-position: -2px -2px;
  background-attachment: local;
}
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) :is(button, input, select, textarea) { font-family: inherit; }

/* ---- header: round ink buttons with drawn icons, a Lilita title ---- */
:is(#sets, #leaderboard, #progress, #dictation) .game-head { padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 10px max(24px, env(safe-area-inset-left)); gap: 16px; }
:is(#sets, #leaderboard, #progress, #dictation) .game-head .icon-btn {
  width: 56px; height: 56px; border-radius: 50%; flex: none; padding: 0;
  display: grid; place-items: center; font-size: 26px; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); box-shadow: var(--hard);
  transition: transform .12s, box-shadow .12s;
}
:is(#sets, #leaderboard, #progress, #dictation) .game-head .icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg.ic { width: 28px; height: 28px; display: block; }
:is(#sets, #leaderboard, #progress) .screen-title {
  font-family: var(--f-display); font-weight: 400; font-size: 42px; line-height: 1; letter-spacing: .5px; margin: 0;
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.screen-title .t-ic { width: 46px; height: 46px; flex: none; display: block; }

/* ---- buttons ---- */
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn {
  background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 20px;
  font-weight: 900; box-shadow: var(--hard); transition: transform .12s, box-shadow .12s;
}
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn.next {
  background: var(--pop-green); color: #fff; border-color: var(--ink); text-shadow: 0 2px 0 rgba(29, 34, 51, .25);
}
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn.speak { background: var(--pop-yellow); }
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn.ghost {
  background: transparent; border-color: rgba(29, 34, 51, .28); box-shadow: none;
}
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .big-btn:disabled { opacity: .45; transform: none; }

/* chips: tabs and toggles */
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .chip {
  background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 999px;
  font-weight: 900; box-shadow: 0 3px 0 var(--ink); transition: transform .12s, box-shadow .12s, background .15s;
}
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .chip.on { background: var(--pop-yellow); border-color: var(--ink); }
:is(#sets, #leaderboard, #progress, #dictation, #word-sheet, #part-sheet) .chip.on::before { content: none; }

/* tab rows (Leaderboard, Brain Garden): one ink-outlined segmented bar */
:is(#leaderboard #lb-tabs, #progress .bg-tabs) {
  display: inline-flex; flex-wrap: wrap; gap: 0; align-self: center; margin: 4px auto 20px;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 5px; box-shadow: var(--hard);
}
:is(#leaderboard #lb-tabs, #progress .bg-tabs) .chip {
  border: 0; box-shadow: none; background: transparent; font-size: 19px; padding: 9px 20px; color: #4a4f63;
}
:is(#leaderboard #lb-tabs, #progress .bg-tabs) .chip.on { background: var(--ink); color: #fff; }
#leaderboard .sets-body, #progress .sets-body { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
#progress .sets-body { display: flex; flex-direction: column; }

/* inputs and selects */
:is(#sets, #dictation) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) {
  border: 3px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); font-weight: 800;
  box-shadow: inset 0 3px 0 rgba(29, 34, 51, .06);
}
:is(#sets, #dictation) :is(input, select, textarea):focus { outline: none; box-shadow: 0 0 0 4px rgba(122, 92, 255, .28); }
:is(#sets, #dictation) :is(input, textarea)::placeholder { color: #b7b0a6; font-weight: 700; }

/* ---- plain sheets: ink card, Lilita heading ---- */
:is(#word-sheet, #part-sheet) { background: rgba(29, 34, 51, .5); }
:is(#word-sheet, #part-sheet) .sheet-card {
  border: 4px solid var(--ink); border-radius: 30px; box-shadow: 0 8px 0 var(--ink); padding: 28px 30px;
  background: var(--paper);
}
:is(#word-sheet, #part-sheet) .sheet-card h2 {
  font-family: var(--f-display); font-weight: 400; font-size: 36px; line-height: 1.05; letter-spacing: .5px;
}

/* ---------- 📚 Word sets ---------- */
#sets .sets-body { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); gap: 18px; }

/* the list (Justin said yes to the canvas): the Writing Desk look from css/desk.css. #sets.desk-screen outranks the
   shared Ink Pop rules above, so the add-a-set steps keep their look and only gain the soft round header button. */
#sets.desk-screen { background-color: var(--a-bg); background-image: linear-gradient(var(--a-grid) 1.5px, transparent 1.5px), linear-gradient(90deg, var(--a-grid) 1.5px, transparent 1.5px); background-size: 84px 84px; background-position: 0 0; }
#sets.desk-screen .game-head .icon-btn { width: 52px; height: 52px; border: 0; background: var(--a-card); color: var(--a-fg); box-shadow: var(--a-sh); }
#sets.desk-screen .game-head .icon-btn:active { transform: translateY(2px); box-shadow: var(--a-sh-sm); }
#sets.desk-screen .game-head .icon-btn svg.ic { width: 26px; height: 26px; }
#sets .screen-title { font-size: 36px; text-wrap: balance; }
#sets .sets-note { margin: 0 0 0 auto; font-weight: 800; font-size: 16px; color: var(--a-mute); text-align: right; }
#sets .sets-note[hidden] { display: none; }

#sets .sets-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 20px; }
#sets .set-card {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr auto;
  align-items: start; gap: 8px 10px; padding: 26px 20px 16px;
  background: var(--a-card); border: 0; border-radius: 20px; box-shadow: var(--a-sh); color: var(--a-fg);
  transition: transform .12s ease-out, box-shadow .12s ease-out;
}
#sets .set-card::before {   /* a colored top edge, cycling through the place colors */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px; background: var(--edge, var(--c-write));
}
#sets .set-card:nth-child(6n+2) { --edge: var(--c-dict); }
#sets .set-card:nth-child(6n+3) { --edge: var(--c-words); }
#sets .set-card:nth-child(6n+4) { --edge: var(--c-inv); }
#sets .set-card:nth-child(6n+5) { --edge: var(--c-lab); }
#sets .set-card:nth-child(6n+6) { --edge: var(--c-paws); }
#sets .set-card:active { transform: none; }   /* pressing the ✓ doesn't press the card */
#sets .set-card:has(.set-open:active) { transform: translateY(2px); box-shadow: var(--a-sh-sm); }
#sets .set-card.fresh { box-shadow: var(--a-sh), 0 0 0 4px var(--a-ok); }
/* tapping anywhere on the card edits the set: the name's button stretches over the whole card… */
#sets .set-open { all: unset; cursor: pointer; min-width: 0; }
#sets .set-open::after { content: ""; position: absolute; inset: 0; border-radius: 20px; }
#sets .set-open:focus-visible::after { box-shadow: inset 0 0 0 3px var(--a-fg); }
#sets .set-name { display: block; font-family: var(--f-display); font-weight: 400; font-size: 25px; line-height: 1.1; overflow-wrap: anywhere; }
#sets .set-count {
  align-self: center; white-space: nowrap; font-weight: 900; font-size: 13px; color: #6f675c;
  background: var(--a-well); border-radius: 999px; padding: 5px 10px;
}
#sets .set-preview {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 16px; align-content: start;
  font-family: var(--f-kai); font-size: 32px; line-height: 1.25; letter-spacing: 3px; color: var(--a-fg);
}
#sets .set-preview > span { white-space: nowrap; }
/* …and the ✓ "Use in Write it!" sits above it, its own 44px box (js/sets.js useInWrite) */
#sets .set-foot {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 2px solid var(--a-well); padding-top: 12px; margin-top: 4px;
}
#sets .set-use {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 8px 0 0;
  border: 0; background: none; cursor: pointer; font: 900 16px/1 var(--f-body); color: #6f675c; white-space: nowrap; flex: none;
}
#sets .set-use.on { color: var(--a-ok); }
#sets .set-use:focus-visible { outline: 3px solid var(--a-fg); outline-offset: 2px; border-radius: 12px; }
#sets .set-use:active .dk-check { transform: scale(.94); }
#sets .set-edit { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 800; font-size: 14px; color: var(--a-mute); white-space: nowrap; }
#sets .sets-add .sa-sub { text-wrap: balance; max-width: 300px; }

/* "Add a set": the last card in the grid */
#sets .sets-add {
  min-height: 220px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 20px; text-align: center;
  background: transparent; border: 3px dashed var(--a-dash); border-radius: 20px; box-shadow: none; cursor: pointer;
  color: var(--a-mute); font: 800 15px/1.35 var(--f-body); min-width: 0; align-self: stretch;
}
#sets .sets-add:active { transform: translateY(2px); background: rgba(255, 253, 248, .6); }
#sets .sets-add .sa-plus { font-size: 46px; line-height: 1; font-weight: 900; color: var(--a-go); }
#sets .sets-add b { font-family: var(--f-display); font-weight: 400; font-size: 24px; color: var(--a-fg); }
#sets .sets-flash { background: var(--a-card); color: var(--a-ok); border: 0; border-radius: 20px; box-shadow: var(--a-sh); font-weight: 800; }
#sets .sets-empty { color: var(--a-mute); font-weight: 700; background: var(--a-card); border-radius: 20px; box-shadow: var(--a-sh); }
#sets .sets-empty b { font-family: var(--f-display); font-weight: 400; font-size: 30px; color: var(--a-fg); }
#sets .sets-empty :is(b, span) { text-wrap: balance; }
@media (max-width: 600px) {
  #sets .sets-note { display: none; }
  #sets .screen-title { font-size: 30px; }
  #sets .set-card { padding: 24px 16px 14px; }
  #sets .set-use { gap: 10px; font-size: 15px; }
  #sets .set-edit { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { #sets .set-card, #sets.desk-screen .game-head .icon-btn { transition: none; } }
#sets .sets-q { font-family: var(--f-display); font-weight: 400; font-size: 36px; }
#sets .add-choice {
  background: #fff; border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 5px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
#sets .add-choice:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); border-color: var(--ink); }
#sets .ac-icon {
  width: 68px; height: 68px; flex: none; display: grid; place-items: center; font-size: 36px;
  border: 3px solid var(--ink); border-radius: 20px; background: var(--c, #efe9ff);
}
#sets #add-copy .ac-icon { --c: #e0f6fb; }
#sets #add-photo .ac-icon { --c: #ffe7ef; }
#sets #add-new .ac-icon { --c: #fff3cf; }
#sets #add-level .ac-icon { --c: #e3f8ee; }
#sets .ac-text b { font-family: var(--f-display); font-weight: 400; font-size: 25px; }
#sets .ac-text small { font-weight: 700; }
#sets .ac-go { color: var(--ink); font-weight: 900; }
#sets .copy-group h2 { font-family: var(--f-display); font-weight: 400; font-size: 28px; }
#sets .copy-row { background: #fff; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); }
#sets .cr-text b { font-weight: 900; }
#sets .cr-hz { font-family: var(--f-brush); font-size: 22px; }
#sets .sets-step { font-weight: 900; letter-spacing: .02em; text-transform: uppercase; font-size: 14px; }
#sets .field-label { font-weight: 900; color: var(--ink); }
#sets .set-help { font-weight: 600; }
#sets .set-help code { background: #f4f0e8; font-weight: 800; }
/* the editor */
#sets .set-name-input { font-family: var(--f-display); font-weight: 400; font-size: 32px; padding: 12px 20px; }
#sets .set-opts label { font-weight: 900; }
#sets .set-opts select { font-size: 18px; padding: 8px 12px; }
#sets .big-btn.small { border-radius: 999px; }
#sets #set-table-view {
  background: #fff; border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 var(--ink); padding: 16px 18px 18px;
}
#sets .set-row-head { color: var(--muted); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
#sets #set-rows .set-row input { border: 2px solid #d9d2c5; box-shadow: none; font-weight: 700; border-radius: 12px; }
#sets #set-rows .set-row input:focus { border-color: var(--pop-violet); box-shadow: 0 0 0 4px rgba(122, 92, 255, .2); }
#sets .set-row .sr-hanzi { font-family: var(--f-brush); font-size: 30px; font-weight: 400; }
#sets .set-row input.auto { color: #9a93a6; }
#sets #set-rows .sr-reading select { border: 0; box-shadow: none; background: #efe9ff; color: var(--pop-violet); }
#sets .sr-del { border-radius: 50%; width: 40px; color: #9a93a6; font-weight: 900; }
#sets .sr-del:active { background: #ffe4e0; color: var(--accent); }
#sets .add-row { border-style: dashed; border-color: rgba(29, 34, 51, .35); border-radius: 999px; }
#sets .fill-banner { background: #efe9ff; border: 3px solid var(--ink); border-radius: 18px; }
#sets .fb-count { color: var(--pop-violet); }
#sets .fb-bar { border: 2px solid var(--ink); height: 14px; }
#sets .fb-bar i { background: var(--pop-violet); }
#sets .set-actions .big-btn { min-width: 150px; border-radius: 999px; }
#sets .link-btn { color: #4a4f63; font-weight: 800; text-decoration-thickness: 2px; text-underline-offset: 4px; }
#sets .link-btn.danger { color: #d23b3b; }

/* ---------- 🏆 Leaderboard: its Writing Desk look is in css/board.css ---------- */

/* ---------- 🎧 Dictation ---------- */
#dictation .progress { height: 18px; background: #fff; border: 3px solid var(--ink); }
#dictation .progress-bar { background: var(--pop-pink); }
#dictation .counter { font-family: var(--f-display); font-weight: 400; color: var(--ink); font-size: 24px; }
/* the setup card: the Writing Desk look (docs/DESIGN.md, the tokens in css/desk.css). While it shows, the header
   has the brush 听 title instead of the progress bar, and the screen is desk paper. The dictation itself keeps Ink Pop. */
#dictation:has(#d-setup:not([hidden])) {
  background-color: var(--a-bg);
  background-image: linear-gradient(var(--a-grid) 1.5px, transparent 1.5px), linear-gradient(90deg, var(--a-grid) 1.5px, transparent 1.5px);
  background-size: 84px 84px; background-position: 0 0;
}
#dictation .d-head-title { display: none; }
#dictation:has(#d-setup:not([hidden])) .d-head-title {
  display: flex; flex: 1; min-width: 0; margin: 0; align-items: center; gap: 10px; white-space: nowrap;
  font-family: var(--f-display); font-weight: 400; font-size: 34px; line-height: 1; color: var(--a-fg);
}
#dictation:has(#d-setup:not([hidden])) :is(.progress, .counter) { display: none; }
#dictation:has(#d-setup:not([hidden])) .game-head .icon-btn { width: 52px; height: 52px; font-size: 22px; border: 0; background: var(--a-card); box-shadow: var(--a-sh); }
#dictation:has(#d-setup:not([hidden])) .game-head .icon-btn svg.ic { width: 26px; height: 26px; }
#dictation:has(#d-setup:not([hidden])) .game-head .icon-btn:active { transform: translateY(2px); box-shadow: var(--a-sh-sm); }
#dictation .d-setup { align-items: flex-start; padding: 12px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
#dictation .d-setup-card {
  position: relative; max-width: 680px; margin: auto; padding: 36px 40px 40px; gap: 22px;
  background: var(--a-card); border: 0; border-radius: 26px; box-shadow: var(--a-sh); color: var(--a-fg);
}
#dictation .d-setup-card::after {   /* a red seal in the corner, like a marked school dictation */
  content: "听写"; position: absolute; top: -18px; right: 30px; writing-mode: vertical-rl;
  font-family: var(--f-brush); font-size: 24px; line-height: 1; letter-spacing: 2px; color: #fff;
  background: var(--a-go); border-radius: 8px; padding: 9px 6px; transform: rotate(6deg); box-shadow: var(--a-sh-sm);
}
#dictation .d-intro { display: flex; align-items: center; gap: 18px; padding-right: 30px; }
#dictation .d-ic { width: 92px; height: 92px; flex: none; }
#dictation .d-blurb { font-weight: 800; color: #4a4540; font-size: 19px; line-height: 1.45; }
#dictation .d-blurb b { color: var(--a-fg); font-weight: 900; }
#dictation .d-label { font-weight: 900; font-size: 19px; margin-bottom: -10px; }
#dictation .d-label small { font-weight: 800; font-size: 15px; color: var(--a-mute); }
#dictation .d-count { align-self: flex-start; }
#dictation .d-count > button { min-width: 64px; min-height: 46px; font-size: 18px; }
#dictation .d-count > button[hidden] { display: none; }
#dictation .d-pinyin-toggle {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 8px 0 0;
  border: 0; background: none; color: var(--a-fg); font-size: 19px; font-weight: 900; cursor: pointer;
}
#dictation .d-pinyin-toggle .tick {   /* the 44px box of .dk-check */
  width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: #fff; box-shadow: inset 0 0 0 3px var(--a-dash); color: #fff;
}
#dictation .d-pinyin-toggle .tick svg { width: 24px; height: 24px; opacity: 0; }
#dictation .d-pinyin-toggle.on-tick .tick { background: var(--a-ok); box-shadow: none; }
#dictation .d-pinyin-toggle.on-tick .tick svg { opacity: 1; }
#dictation .d-pinyin-toggle:focus-visible, #dictation .d-go:focus-visible { outline: 4px solid var(--c-dict); outline-offset: 3px; }
#dictation .d-go { width: 100%; min-height: 64px; margin-top: 4px; font-family: var(--f-display); font-weight: 400; font-size: 28px; }
@media (max-width: 600px) {
  #dictation:has(#d-setup:not([hidden])) .game-head { gap: 10px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  #dictation:has(#d-setup:not([hidden])) .game-head .icon-btn { width: 46px; height: 46px; }
  #dictation:has(#d-setup:not([hidden])) .d-head-title { font-size: 25px; gap: 6px; }
  #dictation .d-setup { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  #dictation .d-setup-card { padding: 28px 18px 22px; gap: 18px; border-radius: 22px; }
  #dictation .d-setup-card::after { right: 18px; font-size: 20px; }
  #dictation .d-intro { gap: 12px; padding-right: 0; }
  #dictation .d-ic { width: 64px; height: 64px; }
  #dictation .d-blurb { font-size: 16px; }
  #dictation .d-label { font-size: 17px; }
  #dictation .d-pinyin-toggle { font-size: 17px; }
  #dictation .d-go { font-size: 24px; }
}
@media (max-height: 500px) {
  #dictation:has(#d-setup:not([hidden])) .game-head { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 4px; }
  #dictation:has(#d-setup:not([hidden])) .game-head .icon-btn { width: 44px; height: 44px; }
  #dictation:has(#d-setup:not([hidden])) .d-head-title { font-size: 26px; }
  #dictation .d-setup { padding-top: 4px; padding-bottom: 12px; }
  #dictation .d-setup-card { padding: 18px 28px 20px; gap: 12px; }
  #dictation .d-setup-card::after { top: -10px; }
  #dictation .d-ic { width: 56px; height: 56px; }
  #dictation .d-blurb { font-size: 16px; }
  #dictation .d-go { min-height: 54px; font-size: 24px; }
}
#dictation .d-main { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
#dictation .d-task { font-weight: 900; color: #4a4f63; }
#dictation .d-prompt .big-btn { border-radius: 999px; }
#dictation .dict-syl { border: 3px dashed #b9b2c4; border-radius: 16px; color: var(--pop-pink); font-weight: 900; background: #fff; }
#dictation .dict-syl.active { border: 3px solid var(--ink); box-shadow: 0 0 0 5px rgba(122, 92, 255, .25); }
#dictation .dict-syl.syl-ok { border: 3px solid var(--pop-green); background: #e8f6ee; color: #1f8a4c; }
#dictation .dict-syl.syl-no { border: 3px solid #f08c00; background: #fff4e6; color: #c2410c; }
/* the pinyin step: each syllable sits above its character on one short, rounded writing line (no box).
   The column widens past the tile for long syllables (zhuàng, shuāng) and the type shrinks only if it must. */
:is(#dictation, #invasion) .dict-one.dict-pystep {
  --pf: clamp(17px, var(--s) * .3, 30px);
  --cmax: calc((min(100cqw, 760px) - 60px - (var(--n, 1) - 1) * 14px) / var(--n, 1));
  --col: min(var(--cmax), max(var(--s), calc(var(--pf) * 3.9 + 12px)));
  --pf2: min(var(--pf), calc((var(--col) - 12px) / 3.9));
}
@media (orientation: landscape) and (max-height: 560px) {
  :is(#dictation, #invasion) .dict-one.dict-pystep { --cmax: calc((36cqw - 40px - (var(--n, 1) - 1) * 14px) / var(--n, 1)); }
}
:is(#dictation, #invasion) .dict-pystep .dict-strip { gap: calc(var(--col) - var(--s) + 14px); }
:is(#dictation, #invasion) .dict-pystep .dict-syls { order: -1; gap: 14px; margin-bottom: 4px; }
:is(#dictation, #invasion) .dict-pystep :is(.dict-syl, .dict-syl.active, .dict-syl.empty) {
  position: relative; width: var(--col); height: calc(var(--pf2) * 1.6); padding: 0; line-height: 1.2;
  font-size: var(--pf2); font-weight: 800; color: var(--ink); border: none; border-radius: 0; box-shadow: none; background: none;
}
:is(#dictation, #invasion) .dict-pystep .dict-syl.empty { color: #c9c2d2; }
:is(#dictation, #invasion) .dict-pystep .dict-syl::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 3px; border-radius: 3px;
  background: #e4ddd1; transition: background .15s, height .15s;
}
:is(#dictation, #invasion) .dict-pystep .dict-syl.active::after { background: #8b5cf6; height: 4px; }
#dictation .dict-py-label { color: var(--muted); font-weight: 900; }
#dictation .dict-key { border-radius: 12px; font-weight: 800; }   /* (the keyboard keeps the canvas's soft keys, style.css) */
#dictation .box { border: 4px solid var(--ink); border-radius: 18px; }
#dictation .box.active { border-color: var(--pop-violet); box-shadow: 0 0 0 6px rgba(122, 92, 255, .2); }
#dictation .dict-tools .big-btn { border-radius: 999px; }
#dictation .d-foot .big-btn { border-radius: 999px; min-height: 64px; font-size: 22px; }
/* results: a big red-ink score stamp and the marked sheet */
#dictation .d-results { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); gap: 18px; }
#dictation .d-results-head {
  background: #fff; border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink); padding: 18px 26px; gap: 26px;
}
#dictation .d-score {
  font-family: var(--f-display); font-weight: 400; font-size: 50px; width: 136px; height: 136px;
  border: 7px double currentColor; background: #fff; box-shadow: 0 0 0 3px currentColor inset;
  animation: d-stamp .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
#dictation .d-score.full { font-size: 38px; letter-spacing: -1px; }
#dictation .d-score.great { color: #e0453a; }
#dictation .d-score.pass { color: #e0453a; }
#dictation .d-score.low { color: #8a8f9e; }
@keyframes d-stamp { from { transform: rotate(-30deg) scale(2.2); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
#dictation .d-verdict { font-family: var(--f-display); font-weight: 400; font-size: 36px; line-height: 1.1; }
#dictation .d-sub { font-weight: 700; }
#dictation .dict-row { background: #fff; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); }
#dictation .dict-row.wrong { background: #fff8f1; border-color: var(--ink); }
#dictation .dict-row .dr-mark { font-family: var(--f-display); font-weight: 400; font-size: 44px; }
#dictation .dict-row.right .dr-mark { color: var(--pop-green); }
#dictation .dict-row.wrong .dr-mark { color: #e0453a; }
#dictation .dr-ink .box { border-width: 3px; }
#dictation .dr-hanzi { font-family: var(--f-brush); font-size: 44px; }
#dictation .dr-pinyin { color: var(--pop-pink); font-weight: 900; }
#dictation .d-results-actions .big-btn { border-radius: 999px; }
@media (prefers-reduced-motion: reduce) { #dictation .d-score { animation: none; transform: rotate(-8deg); } }

/* ---------- 🌻 Brain Garden ---------- */
#progress .game-head .pg-parent { margin-left: auto; }
#progress .bg-summary { gap: 10px; margin-bottom: 18px; }
#progress .bg-summary span {
  background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 5px 14px 5px 10px; box-shadow: 0 3px 0 var(--ink);
  font-weight: 800; color: #4a4f63; display: inline-flex; align-items: center; gap: 6px;
}
#progress .bg-summary b { font-family: var(--f-display); font-weight: 400; font-size: 21px; color: var(--ink); }
#progress .bg-summary .wilt { background: #fff0ec; }
#progress .water-card { border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink); background: #e9f6ff; }
#progress .water-card h3 { font-family: var(--f-display); font-weight: 400; font-size: 28px; color: #1767a8; }
#progress .water-card p { font-weight: 800; }
#progress .wc-go { border-radius: 999px; background: var(--pop-cyan); color: #fff; text-shadow: 0 2px 0 rgba(29, 34, 51, .25); }
#progress .bg-plot { border: 4px solid var(--ink); border-radius: 28px; box-shadow: 0 6px 0 var(--ink); }
#progress .gs-sign { border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); text-shadow: 0 2px 0 rgba(29, 34, 51, .35); border-radius: 12px; }
#progress .gs-sign b { font-family: var(--f-display); font-weight: 400; font-size: 22px; letter-spacing: .3px; }
#progress .gs-soil { border: 3px solid var(--ink); }
#progress .gs-soil .plant-tile b { font-family: var(--f-brush); font-weight: 400; font-size: 30px; border: 2px solid var(--ink); border-radius: 10px; box-shadow: 0 3px 0 #3d2412; }
#progress .gs-soil .plant-tile small { font-weight: 800; }
#progress .gs-soil .plant-tile.wilted b { border-color: #e0453a; background: #fff3f0; }
#progress .pt-stage { font-weight: 900; }
/* Radical Dex: trading cards */
#progress .bg-dex-sub { font-weight: 800; color: #4a4f63; font-size: 17px; max-width: 760px; margin: 0 auto 18px; }
#progress .bg-dex-sub b { font-family: var(--f-display); font-weight: 400; font-size: 30px; color: var(--pop-violet); }
#progress .dex-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 14px; }
#progress .dex-card {
  position: relative; background: #f2eefa; border: 3px dashed rgba(29, 34, 51, .3); border-radius: 18px; padding: 12px 8px 10px; aspect-ratio: 3 / 4; justify-content: center;
}
#progress .dex-card .dex-glyph { font-family: var(--f-brush); font-size: 52px; color: #c9bfdc; filter: blur(2px); }
#progress .dex-card b { font-weight: 900; color: #9a93a6; }
#progress .dex-card small { font-weight: 700; }
#progress .dex-card.caught {
  background: linear-gradient(165deg, #fff 0 45%, #efe9ff); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
}
#progress .dex-card.caught::before {   /* a foil corner */
  content: ""; position: absolute; top: 8px; right: 8px; width: 14px; height: 14px; border-radius: 50%;
  background: conic-gradient(var(--pop-pink), var(--pop-yellow), var(--pop-green), var(--pop-cyan), var(--pop-violet), var(--pop-pink)); border: 2px solid var(--ink);
}
#progress .dex-card.caught .dex-glyph { color: var(--pop-violet); filter: none; }
#progress .dex-card.caught b { color: var(--ink); }
/* Trophies: a wall of medals */
#progress .tr-total { font-family: var(--f-display); font-weight: 400; font-size: 34px; display: flex; align-items: center; gap: 10px; }
#progress .tr-shelf h3 { font-family: var(--f-display); font-weight: 400; font-size: 26px; margin: 14px 0 6px; }
#progress .tr-shelf h3 small { font-family: var(--f-body); font-weight: 900; }
#progress .tr-note { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
#progress .trophies { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 14px; }
#progress .trophy {
  background: #fff; border: 3px dashed rgba(29, 34, 51, .28); border-radius: 22px; padding: 14px 8px 12px; gap: 3px;
  filter: none; opacity: 1;
}
#progress .trophy > span {
  width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; margin-bottom: 4px;
  background: #eeeaf2; border: 3px solid rgba(29, 34, 51, .25); filter: grayscale(1); opacity: .55;
}
#progress .trophy b { font-weight: 900; font-size: 16px; line-height: 1.15; color: #6b6578; }
#progress .trophy small { font-weight: 700; font-size: 12.5px; }
#progress .trophy:not(.got):has(.tr-bar) { opacity: 1; }
#progress .trophy .tr-bar { height: 10px; border: 2px solid rgba(29, 34, 51, .35); background: #f4f0e8; width: 82%; margin-top: 6px; }
#progress .trophy .tr-bar i { background: var(--pop-yellow); }
#progress .trophy em { font-weight: 900; font-size: 12px; }
#progress .trophy.got { background: #fff; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
#progress .trophy.got > span {
  filter: none; opacity: 1; border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff6c8, #ffc22e 70%); box-shadow: 0 3px 0 var(--ink);
}
#progress .trophy.got b { color: var(--ink); }
#progress .trophy.got.tier-silver > span { background: radial-gradient(circle at 35% 30%, #fff, #c5d0db 70%); }
#progress .trophy.got.tier-gold > span { background: radial-gradient(circle at 35% 30%, #fff6c8, #ffb020 70%); }
#progress .trophy.got.tier-silver, #progress .trophy.got.tier-gold { background: #fff; border-color: var(--ink); box-shadow: 0 5px 0 var(--ink); }
#progress .trophy.got.tier-legend { background: linear-gradient(140deg, #fff3c4, #ffd6f0, #d6ecff); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
#progress .trophy.tier-legend:not(.got) { border-color: rgba(122, 92, 255, .32); }
#progress .trophy .tr-pet { color: #b0640a; }
/* Jukebox */
#progress .jb-tune { border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); }
#progress .jb-tune b { font-weight: 900; }
#progress .jb-tune.home { background: #fff3cf; border-color: var(--ink); }
#progress .jb-tune.playing { background: #efe9ff; border-color: var(--ink); }
#progress .jb-tune.locked { box-shadow: none; border-style: dashed; border-color: rgba(29, 34, 51, .35); }

/* the word card and the part card */
:is(#word-sheet, #part-sheet) .sheet-card { width: min(720px, 100%); }
#word-sheet .sheet-actions .big-btn, #part-sheet .sheet-actions .big-btn { border-radius: 999px; }

/* ---------- ☁️ Family account, grown-ups check, pilot families: Living Paper ----------
   These sheets are for parents, so they wear the Parent dashboard's look (css/parents.css):
   warm paper, a serif heading, a vermilion seal. */
:is(#account, #parent-check, #pilot) {
  --lp-paper: #fbf6ea; --lp-card: #fffdf7; --lp-ink: #221d18; --lp-ink2: #463c33; --lp-muted: #7a6b5b;
  --lp-line: #e3d5b9; --lp-verm: #c4381f; --lp-verm-d: #9e2a14; --lp-jade: #3f8e73;
  --lp-serif: "Fraunces", "Iowan Old Style", "Palatino", Georgia, serif;
  --lp-sans: "Nunito", -apple-system, "Segoe UI", system-ui, sans-serif;
  background: rgba(34, 29, 24, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
:is(#account, #parent-check, #pilot) .sheet-card {
  background: var(--lp-paper); color: var(--lp-ink); font-family: var(--lp-sans); font-weight: 600;
  border: 1px solid var(--lp-line); border-radius: 24px; padding: 30px 34px 26px;
  box-shadow: 0 1px 1px rgba(60, 40, 20, .06), 0 30px 60px -20px rgba(34, 20, 8, .45);
  background-image: radial-gradient(700px 300px at 90% -20%, rgba(255, 253, 247, .9), transparent 60%);
}
:is(#account, #parent-check, #pilot) .sheet-card :is(button, input) { font-family: inherit; }
:is(#account, #parent-check, #pilot) .sheet-card h2 {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 14px;
  font: 600 32px/1.1 var(--lp-serif); letter-spacing: -.01em; color: var(--lp-ink);
}
.lp-seal {
  display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 6px;
  background: var(--lp-verm, #c4381f); color: #fff6ea; font: 400 24px/1 "Kaiti SC", "STKaiti", "KaiTi", "Ma Shan Zheng", serif;
  box-shadow: inset 0 0 0 2px var(--lp-verm, #c4381f), inset 0 0 0 3.5px rgba(255, 246, 234, .7); transform: rotate(-4deg);
}
:is(#account, #parent-check, #pilot) .acct-lead { color: var(--lp-ink2); font-weight: 600; font-size: 17px; line-height: 1.5; text-align: center; }
:is(#account, #parent-check, #pilot) .account-card label { font-weight: 800; font-size: 15px; color: var(--lp-ink2); letter-spacing: .02em; }
:is(#account, #parent-check, #pilot) .account-card input {
  background: var(--lp-card); border: 1px solid var(--lp-line); border-radius: 12px; padding: 14px 16px; font-size: 19px; font-weight: 700; color: var(--lp-ink);
  box-shadow: inset 0 1px 2px rgba(60, 40, 20, .08);
}
:is(#account, #parent-check, #pilot) .account-card input:focus { outline: none; border-color: var(--lp-verm); box-shadow: 0 0 0 4px rgba(196, 56, 31, .15); }
:is(#account, #parent-check, #pilot) .big-btn {
  background: var(--lp-card); color: var(--lp-ink); border: 1px solid var(--lp-line); border-radius: 999px;
  box-shadow: 0 1px 0 var(--lp-line); font-weight: 800; font-size: 19px; min-height: 56px;
}
:is(#account, #parent-check, #pilot) .big-btn:active { transform: translateY(1px); }
:is(#account, #parent-check, #pilot) .big-btn.next { background: var(--lp-verm); border-color: var(--lp-verm-d); color: #fff6ea; box-shadow: 0 2px 0 var(--lp-verm-d); }
:is(#account, #parent-check, #pilot) .big-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--lp-muted); }
:is(#account, #parent-check, #pilot) .acct-link { min-height: 44px; font-size: 16px; text-decoration: underline; text-underline-offset: 4px; }
:is(#account, #parent-check, #pilot) .acct-parents {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 14px;
  background: #fffdf7; border: 1px solid var(--lp-line); font-family: var(--lp-serif); font-weight: 600; font-size: 19px;
}
:is(#account, #parent-check, #pilot) .acct-msg { color: var(--lp-jade); }
:is(#account, #parent-check, #pilot) .acct-msg.bad { color: var(--lp-verm); }
:is(#account, #parent-check, #pilot) .pilot-list li { border: 1px solid var(--lp-line); background: var(--lp-card); }
.lp-seal.sm { width: 30px; height: 30px; font-size: 17px; border-radius: 5px; }

/* 说中文！ the 听写 verdict and Next button: Chinese first, English under (docs/LANGUAGE.md) */
#dictation .d-verdict .bark { align-items: flex-start; }
#dictation .d-verdict .bark > b { font-family: var(--f-kai, "Kaiti SC", STKaiti, KaiTi, serif); font-size: 1.25em; }
#dictation .d-verdict .bark > small { font-family: var(--f-body, sans-serif); font-size: .45em; }
#dictation .d-verdict .bark > em { font-family: var(--f-body, sans-serif); font-size: .5em; opacity: .85; }
#dictation .d-btn-zh { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; }
#dictation .d-btn-zh > small { font-size: .72em; font-weight: 800; opacity: .8; }
/* 🏆 a trophy you can go and play for (js/braintree.js goPlay) */
#progress .trophy.tr-go { cursor: pointer; }
#progress .trophy.tr-go:active { transform: translateY(2px); }
#progress .trophy .tr-play { display: inline-block; margin-top: 4px; font-style: normal; font-weight: 900; font-size: 12px; color: #fff; background: #e0362c; border-radius: 999px; padding: 2px 9px; }
/* 💬 the meaning check after a right word (js/meaningcheck.js, css/pinyincheck.css): four answers under the word */
#dictation .d-mkeys { width: min(100%, 680px); gap: 12px; }
#dictation .d-mkeys .big-btn { min-height: 64px; border-radius: 999px; justify-content: center; }
#dictation .d-mkeys .big-btn.right:disabled { background: #d7f7e6; border-color: #2ec27e; box-shadow: 0 4px 0 #1e9e62; color: #146c43; opacity: 1; }
#dictation .d-mkeys .big-btn.wrong:disabled { background: var(--violet-soft, #eeeaff); border-color: var(--violet-deep, #5a48d6); box-shadow: 0 4px 0 var(--violet-deep, #5a48d6); color: #3d2fa8; opacity: 1; }
/* the word opened from ✏️ Edit in My words: a glow so the kid sees which row to fix */
#sets #set-rows .set-row.fixing { border-radius: 14px; box-shadow: 0 0 0 3px #e89a1c; transition: box-shadow .6s; }
