:root {
  --bg: #fff8ee;
  --card: #ffffff;
  --ink: #2d2a26;
  --muted: #8a8177;
  --accent: #e0573e;
  --green: #4caf7d;
  --line: #efe6d8;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* `hidden` always wins over a component's own display */
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- Home ---------- */
#home { overflow-y: auto; padding: max(20px, env(safe-area-inset-top)) 24px 32px; }
.home-head { display: flex; align-items: center; justify-content: space-between; }
.home-head h1 { font-size: 40px; margin: 8px 0; }
.stars-total { font-size: 28px; font-weight: 700; background: var(--card); padding: 8px 18px; border-radius: 999px; box-shadow: var(--shadow); }
.games { display: flex; gap: 16px; margin: 16px 0 8px; flex-wrap: wrap; }
.game-btn {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 16px;
  align-items: center; text-align: left;
  background: var(--accent); color: #fff; border: 0; border-radius: 24px;
  padding: 20px 28px; box-shadow: 0 6px 0 #b8432e; min-width: 320px;
}
.game-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8432e; }
.game-icon { grid-row: span 2; font-size: 48px; }
.game-name { font-size: 30px; font-weight: 800; }
.game-sub { font-size: 16px; opacity: 0.9; }
.list-title { font-size: 22px; color: var(--muted); margin: 24px 0 12px; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.word-card {
  background: var(--card); border: 2px solid var(--line); border-radius: 20px;
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: var(--shadow);
}
.word-card:active { transform: scale(0.97); }
.wc-hanzi { font-size: 48px; line-height: 1.2; }
.wc-pinyin { font-size: 18px; color: var(--muted); }
.wc-stars { font-size: 20px; color: #f2b01e; letter-spacing: 2px; }

/* ---------- Write game ---------- */
.game-head {
  display: flex; align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) 20px 8px;
}
.icon-btn { font-size: 30px; background: var(--card); border: 0; border-radius: 16px; width: 60px; height: 60px; box-shadow: var(--shadow); }
.progress { flex: 1; height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); width: 0; transition: width 0.3s; }
.counter { font-size: 20px; font-weight: 700; color: var(--muted); min-width: 70px; text-align: right; }

.write-main { flex: 1; display: flex; gap: 16px; padding: 8px 20px; min-height: 0; }
.word-info {
  width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px;
  justify-content: center;
}
.pinyin { font-size: 44px; font-weight: 700; color: var(--accent); text-align: center; line-height: 1.1; }
.meaning { font-size: 26px; text-align: center; color: var(--ink); margin-bottom: 12px; }
.mistakes { text-align: center; font-size: 20px; color: var(--muted); min-height: 1.5em; }

.big-btn {
  background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  font-size: 22px; font-weight: 700; padding: 14px 18px; min-height: 64px;
  box-shadow: var(--shadow);
}
.big-btn:active { transform: translateY(3px); box-shadow: none; }
.big-btn.speak { background: #fff1d6; border-color: #f6d79a; font-size: 26px; }
.big-btn.next { background: var(--green); border-color: var(--green); color: #fff; }
.big-btn.ghost { background: transparent; box-shadow: none; }

.boxes {
  flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 24px; touch-action: none; min-width: 0;
}
.box {
  position: relative; background: var(--card); border-radius: 18px;
  border: 4px solid var(--line);
  /* 田字格 practice grid */
  background-image:
    linear-gradient(to right, transparent calc(50% - 1px), #f1e7da calc(50% - 1px), #f1e7da calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), #f1e7da calc(50% - 1px), #f1e7da calc(50% + 1px), transparent calc(50% + 1px));
  transition: border-color 0.2s, opacity 0.2s, transform 0.2s;
}
.box.active { border-color: var(--accent); box-shadow: 0 0 0 6px rgba(224, 87, 62, 0.15); }
.box.waiting { opacity: 0.45; pointer-events: none; }
.box.done { border-color: var(--green); pointer-events: none; }
.box.error { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; }
.box svg { display: block; }

.game-foot {
  display: flex; gap: 16px; justify-content: space-between;
  padding: 8px 20px max(16px, env(safe-area-inset-bottom));
}
.game-foot .big-btn { min-width: 150px; }

.celebrate {
  position: fixed; inset: 0; background: rgba(45, 42, 38, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.celebrate[hidden] { display: none; }
.celebrate-card {
  background: var(--card); border-radius: 32px; padding: 32px 48px; text-align: center;
  animation: pop 0.35s ease-out;
}
.celebrate-stars { font-size: 64px; letter-spacing: 8px; }
.celebrate-word { font-size: 110px; line-height: 1.2; }
.celebrate-text { font-size: 30px; font-weight: 800; margin-bottom: 20px; }
.celebrate-actions { display: flex; gap: 16px; justify-content: center; }
.celebrate-actions .big-btn { min-width: 160px; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* portrait iPad / phones: word info on top */
@media (orientation: portrait), (max-width: 700px) {
  .write-main { flex-direction: column; }
  .word-info { width: auto; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; }
  .pinyin { font-size: 34px; width: 100%; }
  .meaning { font-size: 22px; width: 100%; margin: 0; }
  .word-info .big-btn { flex: 1; min-width: 120px; font-size: 18px; }
  .mistakes { width: 100%; min-height: 1.2em; }
  .game-foot .big-btn { min-width: 0; flex: 1; }
  .home-head h1 { font-size: 30px; }
  .game-btn { min-width: 0; width: 100%; }
}

/* ---------- Profiles ---------- */
.home-head { gap: 16px; }
.home-head h1 { flex: 1; }
.profile-badge {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 0;
  border-radius: 999px; padding: 6px 18px 6px 6px; box-shadow: var(--shadow);
}
.pb-avatar { font-size: 36px; width: 52px; height: 52px; border-radius: 50%; background: #fff1d6; display: grid; place-items: center; }
.pb-name { font-size: 22px; font-weight: 800; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-list { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin: 8px 0 20px; }
.profile-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 150px; padding: 16px 8px;
  background: var(--bg); border: 4px solid var(--line); border-radius: 24px;
}
.profile-pick.on { border-color: var(--accent); }
.profile-pick:active { transform: scale(0.96); }
.pp-avatar { font-size: 64px; line-height: 1.1; }
.pp-name { font-size: 22px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.removing .profile-pick { border-color: #f3a6a6; background: #fff1f1; }
.removing .profile-pick .pp-avatar::after { content: " ✖"; font-size: 28px; color: #d64545; vertical-align: top; }
#profile-remove.pressing { background: #ffe1e1; transition: background 1s; }
.pp-gone-title { flex-basis: 100%; text-align: center; font-size: 18px; font-weight: 800; color: var(--muted); margin: 12px 0 0; }
.profile-pick.gone { opacity: 0.6; border-style: dashed; background: var(--bg) !important; border-color: var(--line) !important; }
.removing .profile-pick.gone .pp-avatar::after { content: " ↩︎"; color: var(--green); }
.profile-pick:disabled { opacity: 0.5; }
#parent-check { z-index: 30; }
.pp-stars { font-size: 16px; color: var(--muted); }

/* ---------- Sheets (picker, profiles) ---------- */
.sheet {
  position: fixed; inset: 0; background: rgba(45, 42, 38, 0.45); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sheet[hidden] { display: none; }
.sheet-card {
  background: var(--card); border-radius: 32px; padding: 24px 28px; width: min(640px, 100%);
  max-height: 100%; overflow-y: auto; animation: pop 0.25s ease-out;
}
.sheet-card h2 { margin: 0 0 16px; font-size: 28px; text-align: center; }
.sheet-actions { display: flex; gap: 12px; justify-content: flex-end; }
.sheet-actions .big-btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.chip {
  background: var(--bg); border: 3px solid var(--line); border-radius: 999px;
  padding: 10px 18px; font-size: 20px; font-weight: 700;
}
.chip small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.chip.on { background: #e8f6ee; border-color: var(--green); }
.chip.on::before { content: "✓ "; color: var(--green); }
.big-btn:disabled { opacity: 0.5; }

/* ---------- Word set manager ---------- */
.game-btn.sets-btn { background: #5b8def; box-shadow: 0 6px 0 #3f6cc4; }
.game-btn.sets-btn:active { box-shadow: 0 2px 0 #3f6cc4; }
.screen-title { font-size: 28px; margin: 0; }
#sets { overflow-y: auto; }
.sets-body { padding: 8px 20px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.sets-body[hidden] { display: none; }
.sets-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.set-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 16px 18px; box-shadow: var(--shadow);
}
.set-card:active { transform: scale(0.98); }
.set-name { font-size: 22px; font-weight: 800; }
.set-count { color: var(--muted); }
.set-preview { font-size: 24px; letter-spacing: 2px; }
.set-name-input, .set-textarea {
  width: 100%; font: inherit; border: 2px solid var(--line); border-radius: 16px; background: var(--card);
  padding: 12px 16px; -webkit-user-select: text; user-select: text;
}
.set-name-input { font-size: 24px; font-weight: 800; }
.set-textarea { min-height: 320px; font-size: 20px; line-height: 1.6; resize: vertical; }
.set-help { color: var(--muted); font-size: 15px; line-height: 1.5; }
.set-help code { background: var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink); }
.set-opts { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.set-opts label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); }
.set-opts select {
  font: inherit; font-size: 18px; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px;
}
.big-btn.small { font-size: 18px; min-height: 48px; padding: 8px 14px; margin-left: auto; }
.set-table-view, .set-paste-view { display: flex; flex-direction: column; gap: 8px; }
.set-status { color: var(--ink); }
.fill-banner {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  background: #eef3fd; border: 2px solid #c9d8f6; border-radius: 16px; padding: 12px 16px; font-size: 17px;
}
.fb-count { font-weight: 800; color: #3f6cc4; font-size: 20px; }
.fb-bar { grid-column: 1 / -1; height: 10px; border-radius: 99px; background: #fff; overflow: hidden; }
.fb-bar i { display: block; height: 100%; width: 0; background: #5b8def; border-radius: 99px; transition: width 0.4s; }
.auto-sample { font-style: italic; }
.link-btn { background: none; border: none; padding: 0; color: #3f6cc4; font-weight: 700; text-decoration: underline; }
.set-rows { display: flex; flex-direction: column; gap: 6px; }
.set-row {
  display: grid; grid-template-columns: minmax(90px, 1.2fr) minmax(110px, 1.3fr) 2fr 40px; gap: 8px; align-items: center;
}
.set-row-head { color: var(--muted); font-size: 13px; font-weight: 700; padding: 0 4px; }
.set-row input {
  width: 100%; min-width: 0; font: inherit; font-size: 18px; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px; background: var(--card); padding: 8px 10px;
  -webkit-user-select: text; user-select: text;
}
.set-row input:focus { outline: none; border-color: #5b8def; }
.set-row .sr-hanzi { font-size: 26px; padding: 4px 10px; }
.set-row .sr-hanzi.missing { color: var(--accent); text-decoration: underline wavy; }
.set-row.bad .sr-hanzi { border-color: #f3b4a6; background: #fff3f0; }
.set-row input.auto { color: var(--muted); font-style: italic; }
.sr-reading { position: relative; display: flex; }
.sr-reading input { padding-right: 36px; }
/* the ▾ menu sits inside the reading box; the native picker opens on tap */
.sr-reading select {
  position: absolute; right: 2px; top: 2px; bottom: 2px; width: 34px;
  font: inherit; font-size: 22px; font-weight: 800; color: #3f6cc4; text-align: center; text-align-last: center;
  border: none; border-radius: 10px; background: #eef3fd; -webkit-appearance: none; appearance: none;
}
.sr-del { border: none; background: none; color: var(--muted); font-size: 20px; height: 40px; }
.sr-hook { grid-column: 1 / -1; color: var(--muted); font-size: 14px; padding: 0 4px 4px; }
.add-row { align-self: flex-start; font-size: 18px; min-height: 48px; }
.set-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
/* each kid's sets: what just happened, the empty state, adding a set */
.set-card.fresh { border-color: var(--green); animation: pop 0.35s ease-out; }
.sets-flash { margin: 0; background: #e8f6ee; border: 2px solid #bfe6cf; border-radius: 16px; padding: 12px 16px; font-size: 18px; font-weight: 700; }
.sets-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 16px; color: var(--muted); font-size: 18px; }
.sets-empty b { color: var(--ink); font-size: 22px; }
.se-icon { font-size: 56px; }
.sets-add { align-self: center; min-width: 280px; font-size: 24px; }
.sets-q { margin: 8px 0 0; font-size: 26px; text-align: center; }
.add-choice {
  display: flex; align-items: center; gap: 18px; text-align: left; width: min(640px, 100%); align-self: center;
  background: var(--card); border: 3px solid var(--line); border-radius: 24px; padding: 20px 22px; box-shadow: var(--shadow);
}
.add-choice:active { transform: scale(0.98); border-color: var(--green); }
.ac-icon { font-size: 44px; }
.ac-text { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ac-text b { font-size: 22px; }
.ac-text small { color: var(--muted); font-size: 16px; }
.ac-go { font-size: 36px; color: var(--muted); }
.copy-groups { display: flex; flex-direction: column; gap: 22px; }
.copy-group h2 { margin: 0 0 10px; font-size: 22px; }
.copy-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--line);
  border-radius: 18px; padding: 12px 14px; margin-bottom: 10px;
}
.cr-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cr-text b { font-size: 20px; }
.cr-text small { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-hz { color: var(--ink); font-size: 18px; letter-spacing: 1px; }
.copy-row .big-btn.small { margin-left: 0; white-space: nowrap; }
.copy-row .has { color: var(--green); opacity: 1; }
.sets-step { margin: 0; color: var(--muted); font-weight: 700; font-size: 15px; }
.field-label { font-weight: 700; color: var(--muted); margin-bottom: -8px; }
.sets-error { margin: 0; color: var(--accent); font-weight: 700; }
.set-more { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; padding-top: 4px; font-size: 17px; }
.link-btn.danger { color: var(--accent); }
.set-give { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.set-give .chip:disabled { opacity: 0.6; }
@media (orientation: portrait), (max-width: 700px) {
  .set-textarea { min-height: 200px; }
  .set-row { grid-template-columns: 1fr 1.3fr 36px; }
  .set-row .sr-meaning { grid-column: 1 / 3; grid-row: 2; }
  .set-row .sr-del { grid-row: 1 / 3; grid-column: 3; }
  .set-row:not(.set-row-head) { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .set-row-head { display: none; }
  .pb-name { display: none; }
  .profile-badge { padding: 6px; }
}

/* ---------- Brainrot Invasion ---------- */
.game-btn.invasion-btn { background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 6px 0 #7a3aa8; }
.game-btn.invasion-btn:active { box-shadow: 0 2px 0 #7a3aa8; }
#invasion { background: linear-gradient(#8fd3ff, #d6f0ff 70%, #eaf8e2); position: relative; overflow: hidden; touch-action: none; }
.inv-hud {
  display: flex; align-items: center; gap: 14px; z-index: 5;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
}
.inv-level { font-size: 26px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #3d6fa0; }
.inv-combo { flex: 1; font-size: 24px; font-weight: 900; color: #ff7a1a; text-shadow: 0 2px 0 #fff; }
.inv-aura {
  font-size: 26px; font-weight: 900; background: #fff; border-radius: 999px; padding: 6px 18px;
  box-shadow: var(--shadow); color: #8b5cf6;
}
.inv-field { position: relative; flex: 1; overflow: hidden; }
.inv-cloud {
  position: absolute; width: 180px; height: 60px; background: #fff; border-radius: 999px; opacity: 0.7;
  animation: drift 40s linear infinite;
}
.inv-cloud::before { content: ""; position: absolute; width: 90px; height: 70px; left: 40px; top: -32px; background: #fff; border-radius: 50%; }
.inv-cloud.c1 { top: 8%; left: -10%; }
.inv-cloud.c2 { top: 28%; left: 40%; animation-duration: 55s; animation-delay: -20s; transform: scale(0.7); }
.inv-cloud.c3 { top: 15%; left: 70%; animation-duration: 48s; animation-delay: -35s; transform: scale(0.85); }
@keyframes drift { from { translate: -30vw 0; } to { translate: 110vw 0; } }

.inv-garden {
  position: absolute; left: 0; right: 0; bottom: 0; height: min(24vh, 170px);
  background: linear-gradient(transparent 55%, #7cc26a 55%, #5aa84a);
}
.plant {
  position: absolute; bottom: 4px; width: min(14vh, 110px); translate: -50% 0;
  transform-origin: bottom center; transition: transform 0.4s, filter 0.4s;
}
.plant svg { display: block; width: 100%; }
.plant .flower { transform-origin: 50% 38%; animation: sway 3s ease-in-out infinite; }
.plant.dead { transform: scaleY(0.45) rotate(-8deg); filter: grayscale(1) brightness(0.8); }
.plant.dead .flower { animation: none; }
@keyframes sway { 50% { transform: rotate(8deg); } }

.inv-mascot { position: absolute; left: 12px; bottom: 8px; width: min(15vh, 110px); z-index: 3; }
.inv-mascot .mascot-svg { display: block; width: 100%; }
.inv-mascot.hop { animation: hop 0.4s; }
.inv-mascot.panic { animation: shake 0.5s; }
.inv-mascot.panic .m-mouth { d: path("M50 84 q10 -10 20 0"); }
.bubble {
  position: absolute; bottom: 100%; left: 40%; white-space: nowrap; background: #fff; border-radius: 16px;
  padding: 8px 14px; font-size: 20px; font-weight: 900; box-shadow: var(--shadow);
}
.bubble[hidden] { display: none; }
@keyframes hop { 40% { transform: translateY(-18px); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.enemy {
  position: absolute; left: 0; top: 0; z-index: 2; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; will-change: transform;
}
.enemy .critter { width: 100%; display: block; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.15)); }
.enemy .legs { animation: kick 0.5s ease-in-out infinite alternate; transform-origin: 50% 70%; }
.enemy.ballerina .critter { animation: spin 3s linear infinite; }
.enemy.croc .prop { animation: blink 0.1s steps(2) infinite; }
@keyframes kick { to { transform: rotate(6deg); } }
@keyframes spin { 50% { transform: scaleX(-1); } }
@keyframes blink { 50% { opacity: 0.2; } }
.sign {
  background: #fff7e6; border: 4px solid #b07f4c; border-radius: 14px; padding: 2px 12px 4px;
  text-align: center; margin-bottom: -6px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); z-index: 1;
}
.sign-hanzi { font-size: 40px; line-height: 1.15; font-weight: 700; white-space: nowrap; }
.sign-pinyin { font-size: 16px; color: var(--accent); font-weight: 700; }
.enemy .hp { font-size: 16px; }
.enemy.caught { z-index: 4; }
.enemy.caught .sign { border-color: var(--accent); box-shadow: 0 0 0 6px rgba(224, 87, 62, 0.35); }
.enemy.boom { animation: boom 0.5s forwards; pointer-events: none; }
.enemy.splat { animation: splat 0.5s forwards; pointer-events: none; }
@keyframes boom { 40% { scale: 1.3; filter: brightness(2); } to { scale: 0; rotate: 360deg; opacity: 0; } }
@keyframes splat { to { scale: 1.4 0.2; opacity: 0; translate: 0 40px; } }
.pop {
  position: absolute; z-index: 6; translate: -50% 0; font-size: 28px; font-weight: 900; color: #8b5cf6;
  text-shadow: 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff; pointer-events: none;
  animation: rise 1.2s ease-out forwards; white-space: nowrap;
}
@keyframes rise { to { transform: translateY(-80px); opacity: 0; } }

.inv-banner {
  position: absolute; top: 30%; left: 50%; translate: -50% 0; z-index: 12; text-align: center;
  background: rgba(255, 255, 255, 0.92); border-radius: 28px; padding: 20px 40px; animation: pop 0.3s ease-out;
  pointer-events: none;
}
.inv-banner[hidden] { display: none; }
.inv-banner-title { font-size: 48px; font-weight: 900; color: #8b5cf6; }
.inv-banner-sub { font-size: 24px; font-weight: 700; color: var(--muted); }

.inv-panel {
  position: absolute; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center;
  background: rgba(30, 20, 60, 0.25); padding: 16px;
}
.inv-panel[hidden] { display: none; }
.inv-panel.shatter .ip-card { animation: shatter 0.35s forwards; }
@keyframes shatter { to { scale: 0.6; rotate: -8deg; opacity: 0; filter: blur(4px); } }
.ip-card {
  background: var(--card); border-radius: 28px; padding: 16px 20px 20px; animation: pop 0.2s ease-out;
  display: flex; flex-direction: column; gap: 12px; align-items: center; max-width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.ip-prompt { display: flex; align-items: center; gap: 16px; }
.ip-prompt .big-btn { min-height: 56px; padding: 8px 16px; }
.ip-pinyin { font-size: 36px; font-weight: 800; color: var(--accent); }
.ip-meaning { font-size: 22px; color: var(--ink); }
.ip-boxes { display: flex; gap: 16px; justify-content: center; touch-action: none; width: min(90vw, 1000px); }
.ip-timer { width: 100%; height: 18px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ip-timer-bar { height: 100%; width: 100%; background: var(--green); border-radius: 999px; }
.ip-timer-bar.low { background: var(--accent); animation: blink 0.3s steps(2) infinite; }

.inv-card { text-align: center; }
.inv-title { font-size: 34px; font-weight: 900; margin-bottom: 8px; }
.inv-story { font-size: 20px; line-height: 1.5; margin: 0 0 12px; }
.inv-best { font-size: 20px; font-weight: 800; color: #8b5cf6; margin-bottom: 14px; }
#inv-difficulty { justify-content: center; }
.inv-go { width: 100%; font-size: 30px; min-height: 76px; }
.inv-stats { display: flex; justify-content: center; gap: 28px; margin: 12px 0; }
.inv-stats div { display: flex; flex-direction: column; }
.inv-stats b { font-size: 48px; }
.inv-stats span { color: var(--muted); font-size: 18px; }
@media (orientation: portrait), (max-width: 700px) {
  .inv-level { font-size: 20px; }
  .ip-prompt { flex-wrap: wrap; justify-content: center; gap: 8px; }
}

/* scaffolding: fading signs, mastery pips, partial outline */
.sign-pinyin.big { font-size: 24px; }
.sign-meaning { font-size: 16px; font-weight: 700; max-width: 180px; line-height: 1.2; }
.sign-ear { font-size: 22px; }
.sign-ear.big { font-size: 40px; line-height: 1.2; }
.sign-meter { display: flex; gap: 3px; justify-content: center; margin-top: 2px; }
.sign-meter i { width: 8px; height: 8px; border-radius: 50%; background: #e4d6bf; }
.sign-meter i.on { background: #8b5cf6; }
.ip-listen { font-size: 26px; font-weight: 800; color: #8b5cf6; }
.ip-listen[hidden] { display: none; }
.pop.upgrade { color: #ff7a1a; font-size: 30px; }

/* ---------- Sigma Shop & upgrades in play ---------- */
.shop-card { width: min(860px, 100%); }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shop-head .inv-title { margin: 0; }
.shop-sub { color: var(--muted); font-size: 18px; font-weight: 700; margin: 4px 0 16px; }
.shop-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.shop-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: #f6f0ff; border: 3px solid #d9c8ff; border-radius: 22px; padding: 16px 10px;
  box-shadow: 0 5px 0 #c4adf5;
}
.shop-item:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #c4adf5; }
.shop-item:disabled { opacity: 0.45; }
.shop-item.bought { opacity: 1; background: #e8f6ee; border-color: var(--green); box-shadow: none; }
.si-icon { font-size: 56px; line-height: 1.1; }
.si-name { font-size: 20px; font-weight: 900; }
.si-name small { color: #8b5cf6; }
.si-desc { font-size: 15px; color: var(--muted); line-height: 1.3; flex: 1; }
.si-price { font-size: 22px; font-weight: 900; color: #8b5cf6; }
.shop-item.bought .si-price { color: var(--green); }
.shop-empty { grid-column: 1 / -1; text-align: center; font-size: 24px; padding: 20px; }
.inv-items { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.inv-bell { min-height: 52px; padding: 6px 14px; font-size: 22px; background: #fff7d6; border-color: #f6d79a; }
.inv-bell[hidden] { display: none; }
.inv-field.frozen { filter: hue-rotate(160deg) saturate(1.6); }
.zap {
  position: absolute; height: 6px; background: linear-gradient(90deg, #ff4fd8, #fff, #4fd2ff); z-index: 5;
  transform-origin: 0 50%; border-radius: 3px; box-shadow: 0 0 12px #ff4fd8; animation: fade 0.3s forwards;
}
@keyframes fade { to { opacity: 0; } }
.enemy.blocked { animation: blocked 0.5s forwards; pointer-events: none; }
@keyframes blocked { to { translate: 0 -120px; rotate: 30deg; opacity: 0; } }
#ip-hint { min-height: 56px; padding: 8px 16px; background: #fff7d6; border-color: #f6d79a; }
#ip-hint[hidden] { display: none; }
.ip-card { position: relative; }
.ip-flash { position: absolute; top: 40%; left: 50%; translate: -50% 0; font-size: 40px; font-weight: 900; color: #4fa9ff; opacity: 0; pointer-events: none; text-shadow: 0 2px 0 #fff; }
.ip-flash.show { animation: flash-up 1s ease-out; }
@keyframes flash-up { from { opacity: 1; } to { opacity: 0; transform: translateY(-60px); } }
@media (orientation: portrait), (max-width: 700px) {
  .shop-items { grid-template-columns: 1fr; }
  .shop-item { flex-direction: row; text-align: left; }
  .si-icon { font-size: 40px; }
}

/* ---------- Bosses ---------- */
.boss {
  position: absolute; top: 6px; left: 50%; translate: -50% 0; z-index: 1; width: min(46vw, 360px);
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
  animation: boss-in 0.8s ease-out;
}
.boss-name { font-size: 22px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #7a3aa8, 0 0 8px #7a3aa8; white-space: nowrap; }
.boss-hp { width: 100%; height: 16px; background: rgba(255, 255, 255, 0.7); border: 3px solid #7a3aa8; border-radius: 999px; overflow: hidden; margin: 4px 0; }
.boss-hp-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #ff4f6d, #ff9a3c); transition: width 0.3s; }
.boss-body { position: relative; width: 62%; opacity: 0.92; animation: bob 2.4s ease-in-out infinite; }
.boss-body .critter { width: 100%; display: block; filter: drop-shadow(0 0 14px rgba(139, 92, 246, 0.8)); }
.boss-crown { position: absolute; top: -18%; left: 50%; translate: -50% 0; font-size: 54px; rotate: -10deg; }
.boss.hit .boss-body { animation: boss-hit 0.35s; }
.boss.defeated { animation: boss-out 1.2s forwards; }
.boss.escaped { animation: boss-flee 1.2s forwards; }
@keyframes bob { 50% { transform: translateY(12px) rotate(3deg); } }
@keyframes boss-in { from { translate: -50% -120%; } }
@keyframes boss-hit { 30% { transform: translateX(-14px) rotate(-8deg); filter: brightness(2) saturate(2); } 60% { transform: translateX(10px); } }
@keyframes boss-out { 30% { scale: 1.2; filter: brightness(3); } to { scale: 0; rotate: 720deg; opacity: 0; } }
@keyframes boss-flee { to { translate: -50% -150%; opacity: 0; } }
.enemy.nemesis .sign { background: #f1e8ff; border-color: #8b5cf6; }
.inv-banner-sub { max-width: 80vw; }

/* ---------- Tap-and-type items (meaning, pinyin, reading) ---------- */
.inv-panel.shatter .ic-card { animation: shatter 0.35s forwards; }
.ic-card { width: min(720px, 94vw); }
.ic-task { font-size: 28px; font-weight: 900; color: #8b5cf6; }
.ic-prompt { display: flex; align-items: center; gap: 18px; min-height: 64px; }
.ic-prompt .big-btn { min-height: 64px; font-size: 30px; }
.ic-prompt .big-btn[hidden] { display: none; }
.ic-hanzi { font-size: 84px; line-height: 1.1; font-weight: 700; }
.ic-hanzi:empty { display: none; }
.ic-sub { font-size: 32px; font-weight: 800; color: var(--accent); }
.ic-body { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ic-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; }
.ic-choice { font-size: 26px; min-height: 80px; }
.ic-choice:disabled { opacity: 0.35; text-decoration: line-through; }
.yes { background: #e8f6ee !important; border-color: var(--green) !important; color: var(--green); animation: pop 0.3s; }
.nope { animation: shake 0.4s; border-color: var(--accent) !important; }
.sign-kind {
  position: absolute; top: -14px; right: -14px; background: #8b5cf6; color: #fff; border-radius: 999px;
  font-size: 18px; padding: 2px 8px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.sign { position: relative; }
.sign.kind-read .sign-hanzi { font-size: 48px; }
@media (orientation: portrait), (max-width: 700px) {
  .ic-hanzi { font-size: 64px; }
}

/* ---------- Leaderboard, My brain, parent view, trophies, cosmetics, story ---------- */
.game-btn.lb-btn { background: #f2b01e; box-shadow: 0 6px 0 #c48c10; }
.game-btn.lb-btn:active { box-shadow: 0 2px 0 #c48c10; }
.game-btn.brain-btn { background: var(--green); box-shadow: 0 6px 0 #3a8a61; }
.game-btn.brain-btn:active { box-shadow: 0 2px 0 #3a8a61; }
#leaderboard, #progress { overflow-y: auto; }
.lb-rows { display: flex; flex-direction: column; gap: 12px; }
.lb-row {
  display: grid; grid-template-columns: 64px 64px 1fr auto; align-items: center; gap: 12px;
  background: var(--card); border: 3px solid var(--line); border-radius: 22px; padding: 12px 20px; box-shadow: var(--shadow);
}
.lb-row.me { border-color: var(--accent); }
.lb-rank { font-size: 40px; text-align: center; font-weight: 900; color: var(--muted); }
.lb-avatar { font-size: 48px; }
.lb-name { font-size: 28px; font-weight: 900; }
.lb-name small { font-size: 20px; }
.lb-value { font-size: 40px; font-weight: 900; color: #8b5cf6; }

.pg-parent { margin-left: auto; position: relative; overflow: hidden; }
.pg-parent.pressing::after { content: ""; position: absolute; inset: 0; background: rgba(139, 92, 246, 0.35); animation: fill 1s linear; transform-origin: left; }
@keyframes fill { from { transform: scaleX(0); } }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.trophy {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 10px 6px;
  filter: grayscale(1); opacity: 0.45;
}
.trophy.got { filter: none; opacity: 1; border-color: #f2b01e; background: #fff8e1; }
.trophy span { font-size: 40px; }
.trophy b { font-size: 16px; }
.trophy small { font-size: 12px; color: var(--muted); line-height: 1.2; }
.trophy.new { animation: pop 0.5s; }
/* 🏆 trophy shelves (js/progress.js renderTrophies) */
.tr-total { font-size: 22px; font-weight: 800; margin: 0 0 6px; }
.tr-shelf { margin: 0 0 18px; }
.tr-shelf h3 { font-size: 20px; margin: 6px 0 8px; }
.tr-shelf h3 small { font-size: 15px; color: var(--muted); font-weight: 700; margin-left: 6px; }
.tr-note { margin: -4px 0 8px; font-size: 14px; color: var(--muted); }
.trophy .tr-bar { display: block; width: 86%; height: 7px; border-radius: 9px; background: var(--line); margin-top: 4px; overflow: hidden; }
.trophy .tr-bar i { display: block; height: 100%; background: #f2b01e; border-radius: 9px; }
.trophy em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--muted); }
.trophy:not(.got):has(.tr-bar) { opacity: 0.7; }
.trophy.got.tier-silver { border-color: #9aa7b4; background: #f3f6f9; }
.trophy.got.tier-gold { border-color: #e09412; background: #fff1c9; box-shadow: 0 0 0 2px #ffe08a inset; }
.trophy.tier-legend { border-style: dashed; }
.trophy.got.tier-legend { border-style: solid; border-color: #e09412; background: linear-gradient(135deg, #fff3c4, #ffd6f0, #d6ecff); box-shadow: 0 4px 14px rgba(224, 148, 18, 0.35); }
.trophy .tr-pet { color: #b0640a; }
/* 🎵 Jukebox (js/jukebox.js) */
.jb-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.jb-pick { font-size: 17px; padding: 10px 16px; }
.jb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.jb-tune {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px;
  border: 3px solid #e3e6ef; border-radius: 16px; background: #fff; font: inherit; color: inherit; cursor: pointer;
}
.jb-tune .jb-emoji { font-size: 36px; }
.jb-tune b { font-size: 15px; }
.jb-tune small { font-size: 12px; color: var(--muted); }
.jb-tune.home { border-color: #f2b01e; background: #fff8e1; }
.jb-tune.playing { border-color: #7a5cff; background: #f1edff; animation: pop 0.4s; }
.jb-tune.playing .jb-emoji { animation: jb-bob 0.8s ease-in-out infinite alternate; }
.jb-tune.locked { opacity: 0.55; filter: grayscale(1); cursor: default; }
@keyframes jb-bob { to { transform: translateY(-4px) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .jb-tune.playing .jb-emoji { animation: none; } }
.new-trophies { margin-bottom: 14px; }
.new-trophies:empty { display: none; }
.pg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.pg-word {
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--card);
  border: 2px solid var(--line); border-radius: 16px; padding: 10px 4px; box-shadow: var(--shadow);
}
.pg-word b { font-size: 36px; font-weight: 600; }
.pg-word small { color: var(--muted); }
.pg-word.trouble { border-color: #f3b4a6; background: #fff3f0; }
.pg-skills { font-size: 13px; display: flex; gap: 4px; color: var(--muted); min-height: 1em; }
.pg-empty { color: var(--muted); margin: 0; }
.parent-view { background: #f6f0ff; border: 2px solid #d9c8ff; border-radius: 20px; padding: 14px 16px; }
.parent-view[hidden] { display: none; }
.parent-view h2 { margin: 0 0 10px; }
.pv-scroll { overflow-x: auto; }
.pv-table { width: 100%; border-collapse: collapse; font-size: 16px; -webkit-user-select: text; user-select: text; }
.pv-table th, .pv-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #e3d8fb; white-space: nowrap; }
.pv-table th { color: var(--muted); font-size: 13px; }
.pv-hz { font-size: 24px; }
.cosmetics { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.cosmetics .chips { justify-content: center; margin: 0; }
.chip.cosmetic { font-size: 26px; padding: 4px 12px; }
.chip.cosmetic.on::before { content: ""; }
.chip.cosmetic:disabled { opacity: 0.4; }
.inv-story-btn { width: 100%; margin-top: 8px; min-height: 48px; font-size: 18px; }
.inv-mascot.hatted .m-cup { display: none; }
.m-hat { position: absolute; top: -12%; left: 50%; translate: -50% 0; font-size: min(7vh, 52px); pointer-events: none; }
.intro-art { font-size: 80px; letter-spacing: 6px; }
.intro-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.intro-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.intro-dots i.on { background: #8b5cf6; }
.flower-rose .flower ellipse { fill: #ff6f91; }
.flower-blue .flower ellipse { fill: #5fb7ff; }
.flower-rainbow .flower ellipse:nth-child(6n+1) { fill: #ff5b5b; }
.flower-rainbow .flower ellipse:nth-child(6n+2) { fill: #ffa53b; }
.flower-rainbow .flower ellipse:nth-child(6n+3) { fill: #ffe14d; }
.flower-rainbow .flower ellipse:nth-child(6n+4) { fill: #5fd47a; }
.flower-rainbow .flower ellipse:nth-child(6n+5) { fill: #5fb7ff; }
.flower-rainbow .flower ellipse:nth-child(6n+6) { fill: #b07cff; }
@media (orientation: portrait), (max-width: 700px) {
  .lb-row { grid-template-columns: 44px 48px 1fr auto; padding: 10px 14px; }
  .lb-name { font-size: 22px; }
  .lb-value { font-size: 30px; }
}

/* ---------- Batch 1: see-through HUD, parachutes, coins, 没错, pause, level stage ---------- */
/* the top bar floats over the play area so falling brainrot are never hidden behind it */
.inv-hud { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; z-index: 8; }
.inv-hud > * { pointer-events: auto; }
.inv-field { position: absolute; inset: 0; }
.inv-level { text-shadow: 0 2px 0 #3d6fa0, 0 0 6px rgba(61, 111, 160, 0.6); }

/* parachute: the question is the canopy */
.enemy .sign {
  border-radius: 46% 46% 14px 14px / 34% 34% 14px 14px; padding-top: 10px;
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1), opacity 0.15s;
  transform-origin: 50% 100%;
}
.enemy .strings { display: block; width: 74%; height: 20px; margin-top: -2px; transition: opacity 0.2s; }
.enemy .strings path { stroke: #7c5230; stroke-width: 2; fill: none; vector-effect: non-scaling-stroke; }
.enemy.dropping .sign, .enemy.dropping .strings { transform: scale(0.15); opacity: 0; }
.enemy.dropping .critter { filter: drop-shadow(0 -18px 0 rgba(255, 255, 255, 0.5)) drop-shadow(0 -36px 0 rgba(255, 255, 255, 0.25)); }
.enemy.torn .sign { transform: rotate(-9deg) skewX(-6deg); }
.enemy.torn .sign::after { content: "💥"; position: absolute; left: -10px; top: -8px; font-size: 20px; }
.enemy.torn .strings { opacity: 0.4; }
.enemy .sign { margin-bottom: 0; }

.coin {
  position: absolute; left: 0; top: 0; z-index: 3; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc928 60%, #e09b00);
  box-shadow: 0 0 16px rgba(255, 201, 40, 0.9), 0 3px 0 #b77d00; animation: coin-spin 1.2s ease-in-out infinite;
}
@keyframes coin-spin { 50% { scale: 0.85 1; } }

.inv-meicuo {
  position: absolute; top: 34%; left: 50%; translate: -50% -50%; z-index: 20; pointer-events: none;
  font-size: min(18vw, 150px); font-weight: 900; color: #ffcf3f; white-space: nowrap; opacity: 0;
  -webkit-text-stroke: 4px #b8432e; text-shadow: 0 8px 0 #b8432e, 0 0 40px rgba(255, 207, 63, 0.9);
}
.inv-meicuo.show { animation: meicuo 1.3s ease-out; }
@keyframes meicuo {
  0% { opacity: 0; scale: 0.2; rotate: -20deg; }
  20% { opacity: 1; scale: 1.25; rotate: 6deg; }
  35% { scale: 1; rotate: -3deg; }
  80% { opacity: 1; }
  100% { opacity: 0; scale: 1.1; translate: -50% -80%; }
}
#invasion.shake { animation: shake-screen 0.4s; }
@keyframes shake-screen { 20% { translate: -8px 4px; } 40% { translate: 7px -5px; } 60% { translate: -5px 3px; } 80% { translate: 4px -2px; } }

/* level complete: a separate, still stage (no game showing through) */
.sheet.stage { background: linear-gradient(160deg, #8b5cf6, #ec4899 60%, #ffb347); z-index: 25; }
.stage-title { font-size: 40px; font-weight: 900; text-align: center; }
.stage-note { text-align: center; color: var(--muted); font-weight: 700; min-height: 0; }
.stage-note:empty { display: none; }
.shop-card .shop-head { margin-top: 10px; border-top: 2px dashed var(--line); padding-top: 12px; }

.pause-card { width: min(760px, 100%); }
.pause-stats { flex-wrap: wrap; gap: 18px 26px; }
.pause-stats b { font-size: 36px; }
.pause-h { margin: 8px 0; text-align: left; }
.relics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; text-align: center; }
.relic { background: #f6f0ff; border: 2px solid #d9c8ff; border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.relic span { font-size: 34px; }
.relic span small { font-size: 16px; color: #8b5cf6; font-weight: 900; }
.relic small { color: var(--muted); font-size: 13px; line-height: 1.25; }

/* pinyin, step by step: one slot per character, sound first, then tone */
.py-slots { display: flex; gap: 12px; justify-content: center; }
.py-slot {
  min-width: 110px; padding: 6px 14px 10px; border-radius: 18px; text-align: center;
  background: var(--bg); border: 3px dashed var(--line); opacity: 0.6;
}
.py-slot.active { opacity: 1; border-style: solid; border-color: #8b5cf6; box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.15); }
.py-slot.done { opacity: 1; border-style: solid; border-color: var(--green); background: #e8f6ee; }
.py-hz { font-size: 56px; font-weight: 700; line-height: 1.15; }
.py-val { font-size: 30px; font-weight: 900; color: var(--accent); min-height: 1.2em; }
.py-slot.done .py-val { color: var(--green); }
.py-step { font-size: 22px; text-align: center; }
.py-step b { color: #8b5cf6; }
.py-zh { font-size: 28px; font-weight: 800; }
.py-keys { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.py-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.py-key {
  min-width: 58px; min-height: 62px; padding: 0 14px; font-size: 28px; font-weight: 800; border-radius: 16px;
  background: var(--card); border: 3px solid var(--line); box-shadow: var(--shadow);
}
.py-key:active { transform: translateY(3px); box-shadow: none; }
.py-key:disabled { opacity: 0.25; text-decoration: line-through; }
.py-key.sound { min-width: 120px; min-height: 76px; font-size: 34px; background: #f6f0ff; border-color: #d9c8ff; }
.py-key.tone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 110px; min-height: 84px; background: #fff7d6; border-color: #f6d79a; }
.py-key.tone b { font-size: 34px; }
.py-key.tone small { font-size: 14px; color: var(--muted); font-weight: 700; }
.py-key.wide { min-width: 110px; font-size: 22px; }
.py-key.go { background: var(--green); border-color: var(--green); color: #fff; }
@media (orientation: portrait), (max-width: 700px) {
  .py-key.tone { min-width: 76px; }
  .py-key.tone b { font-size: 28px; }
  .py-hz { font-size: 44px; }
}
.ip-timer-bar.hit { animation: timer-hit 0.4s; }
@keyframes timer-hit { 30% { background: #ff3b30; transform: scaleY(1.8); } }

/* ---------- boss intro ---------- */
.sheet.boss-intro { background: radial-gradient(circle at 50% 35%, #5a1a6e, #14051f 70%); z-index: 26; }
.bi-card { width: min(640px, 100%); max-height: 100%; overflow-y: auto; text-align: center; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bi-warning {
  font-size: 22px; font-weight: 900; letter-spacing: 0.12em; color: #14051f; padding: 6px 18px; border-radius: 8px;
  background: repeating-linear-gradient(-45deg, #ffcf3f 0 14px, #ffb000 14px 28px); animation: blink 0.5s steps(2) 6;
}
.bi-art { position: relative; width: min(260px, 50vw); animation: boss-slam 0.7s cubic-bezier(.3, 1.5, .5, 1); }
.bi-art .critter { width: 100%; display: block; filter: drop-shadow(0 0 30px rgba(255, 79, 216, 0.8)); }
.bi-art .boss-crown { position: absolute; top: -16%; left: 50%; translate: -50% 0; font-size: 64px; rotate: -10deg; }
@keyframes boss-slam { from { scale: 3; opacity: 0; rotate: -20deg; } 60% { scale: 0.9; opacity: 1; } }
.bi-name {
  font-size: clamp(30px, 6vw, 52px); font-weight: 900; color: #ffcf3f; line-height: 1.05;
  text-shadow: 0 4px 0 #b8432e, 0 0 24px rgba(255, 207, 63, 0.6); animation: shake 0.5s 0.6s;
}
.bi-twists { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.bi-twists li {
  display: flex; flex-direction: column; gap: 2px; background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 207, 63, 0.5);
  border-radius: 16px; padding: 10px 16px; animation: pop 0.4s backwards;
}
.bi-twists li:nth-child(2) { animation-delay: 0.25s; }
.bi-twists li:nth-child(3) { animation-delay: 0.5s; }
.bi-twists b { font-size: 24px; }
.bi-twists span { font-size: 17px; opacity: 0.9; }
.bi-note { margin: 0; opacity: 0.8; font-size: 16px; }
.bi-go { width: 100%; font-size: 28px; min-height: 72px; }

.ip-phase { font-size: 26px; font-weight: 900; color: #8b5cf6; animation: pop 0.3s; }

/* ---------- Batch 2: level clock, relics, quests, swipe ---------- */
.inv-level.ending { color: #ffcf3f; animation: blink 0.5s steps(2) infinite; }
.inv-items { display: flex; gap: 6px; flex-wrap: wrap; letter-spacing: 0; }
.relic-chip {
  position: relative; width: 46px; height: 46px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--card); font-size: 24px; display: grid; place-items: center; box-shadow: var(--shadow); padding: 0;
}
.relic-chip small {
  position: absolute; right: -6px; bottom: -6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: #8b5cf6; color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center;
}
.relic-tip {
  position: absolute; z-index: 30; width: 250px; background: var(--card); border: 2px solid #d9c8ff; border-radius: 16px;
  padding: 10px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; gap: 2px;
  animation: pop 0.2s ease-out;
}
.relic-tip b { font-size: 18px; }
.relic-tip span { color: var(--muted); font-size: 15px; }
.inv-toast {
  position: absolute; top: 84px; left: 50%; translate: -50% 0; z-index: 22; pointer-events: none; max-width: 90%;
  background: #fff8e1; border: 3px solid #f2b01e; border-radius: 18px; padding: 10px 18px;
  font-size: 20px; font-weight: 900; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.inv-toast.show { animation: pop 0.3s ease-out; }
.quests { list-style: none; margin: 4px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.quests:empty { display: none; }
.quests li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  background: #fff8e1; border: 2px solid #f6d79a; border-radius: 14px; padding: 6px 12px; font-size: 16px;
}
.quests li b { font-variant-numeric: tabular-nums; }
.quests li em { font-style: normal; font-weight: 900; color: #8b5cf6; }
.shop-item.relic-pick { background: #e8f6ee; border-color: #9fdcb8; box-shadow: 0 5px 0 #7cc79c; }
.shop-item.relic-pick.rare { background: #fff3c4; border-color: #f2b01e; box-shadow: 0 5px 0 #c48c10; }
.shop-item.relic-sale .si-name::after { content: " 🏺"; }
.enemy.sliceable .sign { box-shadow: 0 0 0 4px #ffcf3f, 0 0 18px #ffcf3f; }
.enemy.sliceable .sign::before { content: "⚔️"; position: absolute; left: -14px; top: -14px; font-size: 22px; }
.enemy.sliced { animation: sliced 0.45s forwards; pointer-events: none; }
@keyframes sliced { 30% { filter: brightness(2); } to { clip-path: polygon(0 0, 100% 0, 100% 45%, 0 60%); translate: 30px -40px; rotate: 25deg; opacity: 0; } }
.swipe-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 7; }
#swipe-trail { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; opacity: 0; filter: drop-shadow(0 0 6px #ffcf3f); transition: opacity 0.2s; }
#swipe-trail.on { opacity: 0.9; }

/* daily streak card (home) */
.streak-card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; margin: 12px 0 4px;
  background: #fff8e1; border: 2px solid #f6d79a; border-radius: 18px; padding: 10px 16px;
}
.streak-card.done { background: #e8f6ee; border-color: #9fdcb8; }
.streak-card.cracked { background: #fff3f0; border-color: #f3b4a6; }
.sc-line { font-size: 19px; font-weight: 900; }
.sc-min { font-size: 14px; color: var(--muted); font-weight: 700; text-align: right; }
.sc-bar { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.08); overflow: hidden; order: 3; }
.sc-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9a3c, #ff4f6d); border-radius: 999px; }
.streak-card.done .sc-bar i { background: var(--green); }
@media (orientation: portrait), (max-width: 700px) {
  .boss { top: 74px; }   /* clear of the top bar */
}

/* 🛠 dev mode panel (pause screen) */

/* ---------- Practice: Learn / Write / Test me ---------- */
.w-modes { display: flex; gap: 6px; background: var(--line); border-radius: 16px; padding: 4px; }
.w-modes button {
  flex: 1; border: 0; border-radius: 12px; background: transparent; padding: 8px 4px;
  font-size: 14px; font-weight: 800; color: var(--muted); white-space: nowrap;
}
.w-modes button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.w-test-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.w-test-actions[hidden] { display: none; }
.w-test-actions .next { grid-column: 1 / -1; }
.w-test-actions .big-btn:disabled { opacity: 0.45; }
.w-test-notes { font-size: 17px; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.35; width: 100%; }  /* its own line, wrapped, when .word-info is a row (phones) */
.w-test-notes:empty { display: none; }
.w-test-notes.pass { color: var(--green); font-size: 20px; }
.w-test-notes.fail { color: #c2410c; }
.box.inkpad { touch-action: none; cursor: crosshair; }
.box.inkpad svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.box.inkpad.pass { border-color: var(--green); }
.box.inkpad.fail { border-color: #f08c00; }
.ink-badge {
  position: absolute; top: 8px; right: 8px; padding: 4px 10px; border-radius: 999px; font-weight: 900; font-size: 18px;
  background: var(--green); color: #fff; pointer-events: none;
}
.box.inkpad.fail .ink-badge { background: #f08c00; }
@media (orientation: portrait), (max-width: 700px) {
  .w-modes { width: 100%; }
  .w-test-actions { width: 100%; }
}

/* ---------- 🧩 parts card ---------- */
.parts-card {
  display: flex; gap: 12px; align-items: center; background: #fff8e1; border: 2px solid #f6d79a;
  border-radius: 18px; padding: 10px 12px; text-align: left;
}
.pc-char { flex: none; background: var(--card); border-radius: 12px; }
.pc-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pc-eq { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.pc-eq i { font-style: normal; font-weight: 900; color: var(--muted); }
.pc-part { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; }
.pc-part b { font-size: 30px; color: var(--c); }
.pc-part small { font-size: 12px; font-weight: 800; color: var(--c); }
.pc-story { font-size: 14px; line-height: 1.35; }
.pc-hook { font-size: 14px; font-weight: 800; color: #8b5cf6; }
.w-parts .parts-card { flex-direction: column; text-align: center; }
.w-parts .pc-eq { justify-content: center; }
#ip-parts-btn { min-height: 56px; padding: 8px 14px; background: #fff8e1; border-color: #f6d79a; }
.ip-parts { max-width: min(560px, 90vw); }
.ws-head { display: flex; flex-direction: column; align-items: center; margin-bottom: 12px; }
.ws-head b { font-size: 64px; line-height: 1.1; }
.ws-head span { font-size: 24px; font-weight: 800; color: var(--accent); }
.ws-head small { font-size: 18px; color: var(--muted); }
.ws-parts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
/* the Practice side panel can be taller than the screen now (tabs + parts card): scroll it, top first */
.word-info { justify-content: flex-start; overflow-y: auto; padding: 4px 2px 8px; }
.word-info > * { flex-shrink: 0; }

/* ---------- learning ladder: help button, free writing in the game ---------- */
#ip-help { min-height: 56px; padding: 8px 14px; background: #ffe3e3; border-color: #ffa8a8; }
.ip-free-actions { display: flex; gap: 10px; justify-content: center; }
.ip-free-actions .big-btn { min-height: 56px; }
.ip-free-actions .big-btn:disabled { opacity: 0.45; }
.ip-result { font-size: 24px; font-weight: 900; text-align: center; }
.ip-result:empty { display: none; }
.ip-result.pass { color: var(--green); }
.ip-result.fail { color: #c2410c; font-size: 18px; }

/* ---------- 🎧 听写 Dictation ---------- */
.game-btn.dict-btn { background: #0ea5a4; box-shadow: 0 6px 0 #0b7d7c; }
.game-btn.dict-btn:active { box-shadow: 0 2px 0 #0b7d7c; }
.game-btn.pets-btn { background: #d1497f; box-shadow: 0 6px 0 #a3325f; }
.game-btn.pets-btn:active { box-shadow: 0 2px 0 #a3325f; }
#dictation { overflow: hidden; }
.d-setup { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 20px; overflow-y: auto; }
.d-setup-card {
  background: var(--card); border-radius: 28px; padding: 28px 32px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; max-width: 560px; width: 100%;
}
.d-title { font-size: 34px; font-weight: 900; }
.d-blurb { font-size: 19px; line-height: 1.4; margin: 0; }
.d-label { font-size: 20px; font-weight: 800; }
.d-label small { font-weight: 600; color: var(--muted); margin-left: 6px; }
.d-setup-card .chips { margin: 0; }
.d-setup-card .chip { font-size: 22px; min-width: 70px; }
.d-pinyin-toggle { align-self: flex-start; }
.d-main { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px 20px max(16px, env(safe-area-inset-bottom)); min-height: 0; }
.d-prompt { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.d-task { font-size: 20px; font-weight: 700; color: var(--muted); flex: 1; min-width: 200px; }
.d-card { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.d-foot { display: flex; justify-content: flex-end; }
.d-foot .big-btn { min-width: 220px; }

.dict-py { display: flex; flex-direction: column; gap: 8px; }
.dict-py-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dict-py-label { font-size: 16px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dict-syls { display: flex; gap: 8px; }
.dict-syl {
  min-width: 96px; height: 54px; padding: 0 12px; font: inherit; font-size: 28px; font-weight: 800; color: var(--accent);
  background: var(--card); border: 3px dashed var(--line); border-radius: 14px;
}
.dict-syl.empty { color: var(--muted); font-weight: 600; }
.dict-syl.active { border-style: solid; border-color: #8b5cf6; box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15); }
.dict-py-show { font-size: 28px; font-weight: 800; color: var(--green); }
.dict-py-show b { color: var(--green); }
.dict-py.right .dict-syl { border-style: solid; border-color: var(--green); background: #e8f6ee; color: var(--green); }
.dict-py.wrong .dict-syl { border-style: solid; border-color: #f08c00; background: #fff4e6; color: #c2410c; text-decoration: line-through; }
.dict-py.wrong .dict-py-show { color: #c2410c; }
.dict-kb { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.dict-kb[hidden] { display: none; }
.dict-kb-row { display: flex; gap: 6px; justify-content: center; }
.dict-key {
  font: inherit; font-size: 22px; font-weight: 800; min-width: 46px; height: 46px; padding: 0 6px; border-radius: 10px;
  background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.dict-key.tone { min-width: 70px; background: #fff7d6; border-color: #f6d79a; }
.dict-key.tone small { font-size: 12px; color: var(--muted); }
.dict-key.tone .tone-mark { width: 30px; height: 22px; display: block; }
.dict-key.wide { min-width: 70px; }
.dict-key:active { transform: translateY(3px); box-shadow: none; }
.dict-chars.boxes { flex: 1; min-height: 0; }
.dict-tools { display: flex; gap: 10px; justify-content: center; }
.dict-tools .big-btn { min-height: 52px; font-size: 19px; padding: 8px 18px; }

.d-results { flex: 1; overflow-y: auto; padding: 8px 20px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.d-results-head { display: flex; gap: 20px; align-items: center; }
.d-score {
  font-size: 56px; font-weight: 900; width: 140px; height: 140px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; border: 6px solid currentColor; transform: rotate(-8deg);
  font-variant-numeric: tabular-nums;
}
.d-score.great { color: var(--green); }
.d-score.pass { color: #0ea5a4; }
.d-score.low { color: #e03131; }
.d-verdict { font-size: 28px; font-weight: 900; }
.d-sub { font-size: 18px; color: var(--muted); }
.d-results-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* the marked sheet (Practice and boss exams) */
.dict-sheet { display: flex; flex-direction: column; gap: 10px; }
.dict-row {
  display: grid; grid-template-columns: 44px 28px auto 1fr; gap: 12px; align-items: center;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 10px 14px;
}
.dict-row .dr-mark { font-size: 40px; font-weight: 900; line-height: 1; }
.dict-row.right .dr-mark { color: var(--green); }
.dict-row.wrong .dr-mark { color: #e03131; }
.dict-row.wrong { border-color: #ffd8a8; background: #fffaf3; }
.dr-n { font-weight: 800; color: var(--muted); }
.dr-ink { display: flex; gap: 6px; }
.dr-ink .box { width: 92px; height: 92px; border-width: 3px; border-radius: 12px; pointer-events: none; }
.dr-ink .ink-badge { font-size: 12px; padding: 2px 6px; top: 4px; right: 4px; }
.dr-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-width: 0; }
.dr-hanzi { font-size: 40px; }
.dr-pinyin { font-size: 22px; font-weight: 800; color: var(--accent); }
.dr-meaning { font-size: 17px; color: var(--muted); }
.dr-mine { width: 100%; font-size: 15px; font-weight: 700; }
.dr-mine.ok { color: var(--green); }
.dr-mine.no { color: #c2410c; }
.report-btn { font: inherit; font-size: 14px; font-weight: 700; color: #5c5f66; background: #fff; border: 2px solid #e5dccd; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.report-btn:disabled { color: var(--green); border-color: transparent; background: transparent; cursor: default; }
@media (max-width: 700px) {
  .dict-row { grid-template-columns: 36px 1fr; }
  .dr-n { display: none; }
  .dr-ink, .dr-answer { grid-column: 2; }
}

/* ---------- level-complete stage: compact summary, sold-out items, flying relic ---------- */
.stage-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0 6px; }
.stage-stats div {
  display: flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: var(--bg); border: 2px solid var(--line); font-variant-numeric: tabular-nums;
}
.stage-stats b { font-size: 24px; }
.stage-stats span { font-size: 15px; color: var(--muted); font-weight: 700; }
.quests.compact { margin: 6px 0 4px; gap: 4px; }
.quests.compact li { font-size: 14px; padding: 4px 10px; }
.shop-item.sold { opacity: 0.55; filter: grayscale(0.7); }
.shop-item.sold .si-price { background: #ddd; color: #555; }
.relic-fly {
  position: fixed; z-index: 60; display: flex; align-items: center; justify-content: center; font-size: 48px;
  pointer-events: none; transition: transform 0.7s cubic-bezier(.5, -0.3, .4, 1); filter: drop-shadow(3px 3px 0 #161616);
}

/* boss intro: fits the screen, no scrolling. Landscape: boss on the left, the rules on the right */
.sheet.boss-intro { overflow: hidden; }
.bi-card { overflow: visible; max-height: none; }
.bi-left, .bi-right { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.bi-art { width: min(240px, 50vw, 30vh); }
@media (orientation: landscape) {
  .bi-card { width: min(1040px, 100%); flex-direction: row; align-items: center; gap: 32px; }
  .bi-left { flex: 0 0 40%; }
  .bi-right { flex: 1; align-items: stretch; }
  .bi-art { width: min(300px, 32vw, 42vh); }
}
/* quests: a progress bar under each; on the level-complete stage, three small cards in a row */
.quests li { position: relative; }
.q-bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.08); overflow: hidden; display: block; }
.q-bar i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.quests.compact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 4px; }
.quests.compact li {
  grid-template-columns: 1fr auto; grid-template-rows: 1fr auto auto; gap: 4px 8px; align-items: start;
  padding: 8px 10px; font-size: 14px; line-height: 1.25;
}
.quests.compact li span { grid-column: 1 / -1; }
.quests.compact li::before { content: "🎯"; position: absolute; top: -10px; left: -6px; font-size: 18px; }
/* the shop: a row of small supply cards (Replant, Hint Bulbs, 2 backpack items) over the relics */
#shop-items { display: block; }
.shop-row-h { font-weight: 900; font-size: 18px; margin: 4px 0 8px; }
.shop-row-h small { font-weight: 700; color: var(--muted); font-size: 14px; }
.shop-supplies, .shop-relics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.shop-supplies .shop-item {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "i n" "i d" "i p";
  align-items: center; justify-items: start; text-align: left; padding: 10px 12px; gap: 2px 10px;
}
.shop-supplies .si-icon { grid-area: i; }
.shop-supplies .si-name { grid-area: n; }
.shop-supplies .si-desc { grid-area: d; }
.shop-supplies .si-price { grid-area: p; }
.shop-supplies .si-icon { font-size: 36px; }
.shop-supplies .si-desc { font-size: 13px; }
.shop-supplies .si-name { font-size: 17px; }
.shop-supplies .si-price { font-size: 18px; white-space: nowrap; }
.shop-item .si-name small { font-size: 13px; color: var(--muted); }
.shop-item.pack { background: #eaf6ff; border-color: #b9dcff; box-shadow: 0 5px 0 #8fc3f5; }
/* the shop fits without scrolling on a landscape iPad: 4 supplies in one row, 5 relics in the next */
@media (orientation: landscape) and (min-width: 900px) {
  .shop-card { width: min(1100px, 100%); }
  .shop-supplies { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .shop-relics { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .shop-relics .si-icon { font-size: 44px; }
  .shop-relics .si-desc { font-size: 14px; }
  #pick-items:has(> :nth-child(4)) { grid-template-columns: repeat(4, 1fr); }
}
@media (orientation: portrait), (max-width: 700px) {
  .shop-supplies, .shop-relics { grid-template-columns: 1fr; }
}

/* iPad held upright (portrait): ask to turn it sideways. Phones (narrower) still work upright. */
.rotate-me { display: none; }
@media (orientation: portrait) and (min-width: 600px) {
  .rotate-me {
    position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; background: var(--bg); text-align: center; padding: 24px;
  }
  .rotate-icon { font-size: 96px; animation: rotate-hint 2.4s ease-in-out infinite; }
  .rotate-text { font-size: 36px; font-weight: 900; }
  .rotate-sub { font-size: 20px; color: var(--muted); font-weight: 700; }
}
@keyframes rotate-hint { 0%, 30% { rotate: 0deg; } 60%, 100% { rotate: -90deg; } }
/* shorter screens (most iPads in landscape): tighter spacing so nothing needs scrolling */
@media (max-height: 860px) {
  .word-info { gap: 8px; }
  .word-info .meaning { margin-bottom: 4px; }
  .word-info .big-btn { min-height: 54px; padding: 10px 14px; font-size: 20px; }
  .w-parts .parts-card { padding: 8px; }
  .pause-card .inv-stats { margin: 4px 0; gap: 20px; }
  .pause-card .inv-stats b { font-size: 34px; }
  .pause-card .pause-h { margin: 6px 0 4px; }
}
.pc-part.known { position: relative; }
.pc-part.known::after { content: "✓"; position: absolute; top: -6px; right: -8px; font-size: 12px; font-weight: 900; color: #fff; background: var(--green); border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }
.pc-known { font-size: 14px; font-weight: 800; color: var(--green); }

/* ---------- 🌻 Brain Garden: plants, 🧩 Radical Dex ---------- */
.bg-tabs { justify-content: center; }
.bg-pane[hidden] { display: none; }
.bg-summary { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.bg-summary span {
  background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px;
  font-size: 15px; font-weight: 700; color: var(--muted);
}
.bg-summary b { color: var(--ink); font-size: 18px; }
.bg-summary .wilt { border-color: #f3b4a6; background: #fff3f0; }
.bg-summary .wilt b { color: var(--accent); }
@keyframes water-pulse { 50% { transform: scale(1.02); } }
.bg-plot {
  position: relative; border: 3px solid #7cb860; border-radius: 22px; padding: 64px 12px 14px; overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.25) 0 2px, transparent 3px) 0 0 / 22px 18px,
    linear-gradient(#bfe6ff 0 52px, #8fd16b 52px 58px, #a6dc82 58px);
}
/* sky strip along the top */
.gs-sky { position: absolute; inset: 0 0 auto 0; height: 52px; pointer-events: none; }
.gs-sun { position: absolute; right: 18px; top: 4px; font-size: 38px; animation: gs-spin 30s linear infinite; }
.gs-cloud { position: absolute; top: 8px; font-size: 30px; opacity: 0.9; animation: gs-drift 40s linear infinite; }
.gs-cloud.c1 { left: 10%; }
.gs-cloud.c2 { left: 55%; top: 14px; font-size: 24px; animation-duration: 55s; }
@keyframes gs-spin { to { rotate: 360deg; } }
@keyframes gs-drift { 50% { translate: 60px 0; } }
/* one bed per word set: a wooden sign and rows of tilled soil */
.gs-bed { margin-bottom: 16px; }
.gs-bed:last-child { margin-bottom: 0; }
.gs-sign {
  display: inline-flex; flex-direction: column; margin: 0 0 -4px 14px; position: relative; z-index: 1;
  background: #c98e55; border: 3px solid #7a4c2b; border-radius: 10px; padding: 4px 14px; color: #fff;
  box-shadow: 0 3px 0 #7a4c2b; text-shadow: 0 1px 0 #7a4c2b;
}
.gs-sign b { font-size: 18px; }
.gs-sign small { font-size: 13px; font-weight: 700; opacity: 0.95; }
.gs-sign .wilt { color: #ffe0d8; }
.gs-soil {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px 8px;
  border: 3px solid #6e4224; border-radius: 16px; padding: 14px 10px 8px;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 3px, transparent 3px 26px),
    linear-gradient(#8a5a35, #7a4c2b);
  box-shadow: inset 0 6px 0 rgba(0,0,0,.15);
}

.plant-tile {
  display: flex; flex-direction: column; align-items: center; gap: 0; background: var(--card);
  border: 2px solid #cfe8c4; border-bottom: 8px solid #a9774f; border-radius: 16px 16px 10px 10px;
  padding: 8px 4px 6px; box-shadow: var(--shadow); transition: transform 0.15s;
}
.plant-tile:active { transform: scale(0.96); }
.plant-tile b { font-size: 32px; font-weight: 600; line-height: 1.15; }
.plant-tile small { color: var(--muted); font-size: 13px; }
.pt-plant { font-size: 40px; line-height: 1.1; transform-origin: 50% 100%; }
.plant-tile.st0 .pt-plant { font-size: 26px; padding-top: 12px; }
.plant-tile.st1 .pt-plant { font-size: 32px; padding-top: 6px; }
.plant-tile.st4 .pt-plant { font-size: 48px; margin-top: -6px; }
.plant-tile.st3, .plant-tile.st4 { background: #fffdf0; border-color: #f2d27a; }
.pt-stage { font-size: 12px; font-weight: 800; color: var(--green); text-transform: uppercase; letter-spacing: 0.03em; }
.plant-tile.soil { opacity: 0.6; border-color: var(--line); background: #faf6ef; }
.plant-tile.soil .pt-plant { font-size: 22px; padding-top: 14px; }
.plant-tile.soil .pt-stage { color: var(--muted); }
.plant-tile.wilted { background: #fff3f0; border-color: #f3b4a6; }
.plant-tile.wilted .pt-plant { animation: wilt-sway 2.4s ease-in-out infinite; }
.plant-tile.wilted .pt-stage { color: var(--accent); }
@keyframes wilt-sway { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; } }
.ws-stats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: -4px 0 12px; }
.ws-stats:empty { display: none; }
.ws-stats span { background: #f2fbf2; border: 2px solid #cfe8c4; border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 15px; }
#ws-practice[hidden] { display: none; }

.bg-dex-sub { text-align: center; color: var(--muted); font-weight: 600; margin: 0 0 14px; line-height: 1.4; }
.bg-dex-sub b { color: #8b5cf6; font-size: 20px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.dex-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: #f1eef6; border: 2px dashed #d0c6e0; border-radius: 18px; padding: 10px 6px;
}
.dex-card .dex-glyph { font-size: 44px; line-height: 1.1; color: #c3b8d6; filter: blur(1.5px); }
.dex-card b { font-size: 15px; color: var(--muted); }
.dex-card small { font-size: 12px; color: var(--muted); line-height: 1.2; }
.dex-card.caught {
  background: linear-gradient(160deg, #fff, #f6f0ff); border: 2px solid #b79cf7; box-shadow: 0 4px 0 #d9c8ff;
}
.dex-card.caught .dex-glyph { color: #6d3fe0; filter: none; }
.dex-card.caught b { color: var(--ink); }
.dex-card.new { animation: pop 0.5s; }

/* 🧩 New part caught! / 🔥 NEW RECORD! toasts */
.fx-toast {
  position: fixed; left: 50%; top: 18%; translate: -50% 0; z-index: 60; pointer-events: none;
  background: linear-gradient(160deg, #8b5cf6, #ec4899); color: #fff; border-radius: 22px;
  padding: 14px 22px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); text-align: center;
  font-weight: 900; font-size: 24px; animation: toast-in 0.4s ease-out, toast-out 0.4s ease-in 2.6s forwards;
}
.fx-toast .fx-glyphs { display: block; font-size: 52px; line-height: 1.1; letter-spacing: 6px; }
.fx-toast small { display: block; font-size: 16px; font-weight: 700; opacity: 0.9; }
.fx-toast.record { background: linear-gradient(160deg, #ff7a18, #e0573e); }
@keyframes toast-in { from { opacity: 0; scale: 0.6; } }
@keyframes toast-out { to { opacity: 0; translate: -50% -30px; } }

/* 🔎 Spot the Mistake (games/invasion/challenges.js) */
.spot-wrap { display: flex; gap: 12px; justify-content: center; }
.spot-char {
  width: min(220px, 34vw, 30vh); aspect-ratio: 1; background: #fff; border: 3px solid #e7c9a0;
  border-radius: 14px; touch-action: none; cursor: crosshair;
}
.spot-char path { fill: #2d2a26; }
.spot-char .spot-grid { fill: none; stroke: #f0d9b5; stroke-width: 6; stroke-dasharray: 22 18; }
.spot-char.found { border-color: var(--green) !important; }
.spot-char .spot-miss { fill: rgba(224, 87, 62, 0.25); stroke: var(--accent); stroke-width: 10; }
.spot-char .spot-bad { fill: #e0573e; opacity: 0.45; }
.spot-char .spot-fix { fill: var(--green); animation: spot-fade 0.5s; }
@keyframes spot-fade { from { opacity: 0; } }
.spot-ok { max-width: 360px; width: 100%; }

/* ---------- Music ---------- */
.music-toggle.off { opacity: 0.55; }

/* 💧 Today's watering (Brain Garden + Practice) */
.water-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 14px;
  background: linear-gradient(160deg, #f0f8ff, #e2f1ff); border: 2px solid #9fd0ff; border-radius: 22px;
  padding: 10px 16px; margin: 0 0 16px;
}
.water-card h3 { margin: 0; font-size: 20px; color: #1c64a8; }
.water-card p { margin: 2px 0 6px; color: var(--muted); font-weight: 700; font-size: 15px; }
.water-card.all-done { background: linear-gradient(160deg, #f2fbf2, #e3f6e8); border-color: #9ed9a9; }
.water-card.all-done h3 { color: var(--green); }
.wc-can { width: 96px; }
.can-svg { width: 100%; display: block; }
.can-water { transition: y 0.8s ease, height 0.8s ease; }
.wc-words { display: flex; flex-wrap: wrap; gap: 6px; }
.wc-word { background: #fff; border: 2px solid #cfe4f7; border-radius: 999px; padding: 2px 10px; font-size: 18px; font-weight: 600; }
.wc-word.done { border-color: #9ed9a9; background: #f2fbf2; color: var(--muted); }
.wc-go { background: #3d9cf0; border-color: #1c64a8; color: #fff; animation: water-pulse 1.8s ease-in-out infinite; }
.wc-go[hidden] { display: none; }
@media (max-width: 640px) {
  .water-card { grid-template-columns: auto 1fr; }
  .wc-go { grid-column: 1 / -1; }
}
.w-modes[hidden], .w-stage[hidden] { display: none; }
.w-stage {
  align-self: flex-start; background: #e6f4ff; border: 2px solid #9fd0ff; color: #1c64a8;
  border-radius: 999px; padding: 4px 14px; font-size: 18px; font-weight: 800;
}
#write.watering .progress-bar { background: #3d9cf0; }
.celebrate-stars .can-svg { width: 130px; margin: 0 auto; }

/* 🌱 Your garden grew! (plants that moved up since the last visit) */
.bg-grew {
  text-align: center; font-size: 24px; font-weight: 900; color: var(--green); margin: 0 0 12px;
  background: linear-gradient(160deg, #f2fbf2, #fffbe6); border: 2px solid #9ed9a9; border-radius: 18px; padding: 8px 14px;
}
.bg-grew[hidden] { display: none; }
.bg-grew small { display: block; font-size: 15px; font-weight: 700; color: var(--muted); }
.bg-grew.show { animation: pop 0.5s ease-out, grew-out 0.6s ease-in 7s forwards; }
@keyframes grew-out { to { opacity: 0.0; height: 0; padding: 0; margin: 0; border-width: 0; overflow: hidden; } }
.plant-tile.grew { border-color: #9ed9a9; }
.plant-tile.growing { animation: grew-glow 1.6s ease-out; }
.plant-tile.growing .pt-plant { animation: grow-up 0.9s cubic-bezier(.3,1.6,.5,1); }
.plant-tile.growing::after {
  content: "✨"; position: absolute; top: 2px; right: 6px; font-size: 22px; animation: sparkle 1.2s ease-out forwards;
}
.plant-tile { position: relative; }
@keyframes grow-up { 0% { transform: scale(0.2) translateY(20px); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes grew-glow { 0% { box-shadow: 0 0 0 0 rgba(76, 175, 125, 0.7); } 100% { box-shadow: 0 0 0 16px rgba(76, 175, 125, 0); } }
@keyframes sparkle { from { opacity: 1; transform: scale(0.5); } to { opacity: 0; transform: scale(1.6) translateY(-10px); } }

/* plants in the soil: the plant on a mound, its word on a little white stake */
.gs-soil .plant-tile, .gs-soil .plant-tile.st3, .gs-soil .plant-tile.st4, .gs-soil .plant-tile.soil, .gs-soil .plant-tile.wilted {
  background: transparent; border: 0; box-shadow: none; border-radius: 0; padding: 0 2px 4px; opacity: 1;
}
.gs-soil .plant-tile::before {   /* the mound (a row of these makes a furrow) */
  content: ""; position: absolute; left: 6%; right: 6%; top: 40px; height: 18px; border-radius: 50%;
  background: #5e391e; box-shadow: inset 0 3px 0 rgba(255,255,255,.12);
}
.gs-soil .pt-plant { position: relative; z-index: 1; height: 52px; display: flex; align-items: flex-end; padding: 0 !important; margin: 0 !important; }
.gs-soil .plant-tile.st0 .pt-plant { font-size: 24px; }
.gs-soil .plant-tile.st1 .pt-plant { font-size: 32px; }
.gs-soil .plant-tile.st2 .pt-plant { font-size: 40px; }
.gs-soil .plant-tile.st3 .pt-plant { font-size: 46px; }
.gs-soil .plant-tile.st4 .pt-plant { font-size: 58px; }
.gs-soil .plant-tile.soil .pt-plant { font-size: 28px; color: #c9a27e; }
.gs-soil .plant-tile b, .gs-soil .plant-tile small, .gs-soil .pt-stage { position: relative; z-index: 1; }
.gs-soil .plant-tile b {
  margin-top: 6px; background: #fffaf0; border: 2px solid #d9c3a3; border-radius: 8px; padding: 0 8px;
  font-size: 26px; box-shadow: 0 2px 0 #5e391e;
}
.gs-soil .plant-tile small { color: #f4e3cc; font-weight: 700; }
.gs-soil .pt-stage { color: #c8f2b0; }
.gs-soil .plant-tile.soil b { opacity: 0.55; }
.gs-soil .plant-tile.soil .pt-stage { color: #d9bfa0; }
.gs-soil .plant-tile.wilted b { border-color: #f3b4a6; background: #fff3f0; }
.gs-soil .plant-tile.wilted .pt-stage { color: #ffc2b4; }
.gs-soil .plant-tile.grew b { border-color: #9ed9a9; }
/* 🐛 a brainrot nibbling a wilting plant */
.gs-nibbler {
  position: absolute; z-index: 2; left: calc(50% + 10px); top: 14px; width: 46px; height: 44px;
  animation: gs-nibble 1.1s ease-in-out infinite; transform-origin: 30% 90%; pointer-events: none;
}
.gs-nibbler svg { width: 100%; height: 100%; overflow: visible; }
.gs-nibbler i {
  position: absolute; left: -6px; top: -12px; font-style: normal; font-size: 12px; font-weight: 900; color: #fff;
  text-shadow: 0 0 3px #5e0d1b, 0 0 3px #5e0d1b; animation: gs-nom 1.1s steps(1) infinite; animation-delay: inherit;
}
@keyframes gs-nibble { 0%, 100% { translate: 0 0; rotate: 0deg; } 40% { translate: -8px 2px; rotate: -12deg; } 55% { translate: -6px 0; rotate: -4deg; } }
@keyframes gs-nom { 0%, 30% { opacity: 0; } 40%, 70% { opacity: 1; } }
@media (max-width: 480px) {
  .bg-plot { padding: 60px 6px 10px; }
  .gs-soil { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); padding: 12px 4px 6px; gap: 4px; }
  .gs-soil .plant-tile b { font-size: 22px; padding: 0 5px; }
}

/* 🧩 a part's card: every character that uses it */
.dex-card { font: inherit; cursor: pointer; }
.dex-card:active { transform: scale(0.96); }
.pc-part.tappable { cursor: pointer; border-radius: 10px; padding: 2px 4px; }
.pc-part.tappable:active { background: #f1eef6; }
.ps-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 8px; }
.ps-head b { font-size: 84px; line-height: 1.1; color: #c3b8d6; }
.ps-head b.caught { color: #6d3fe0; }
.ps-head span { font-size: 22px; font-weight: 800; }
.ps-head small { color: var(--muted); font-weight: 700; font-size: 15px; }
.ps-body { max-height: 52vh; overflow-y: auto; margin-bottom: 12px; }
.ps-body h3 { margin: 12px 0 8px; font-size: 17px; }
.ps-body h3 small { color: var(--muted); }
.ps-chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ps-char {
  position: relative; display: flex; flex-direction: column; align-items: center; font: inherit; cursor: pointer;
  background: #fffdf0; border: 2px solid #f2d27a; border-radius: 14px; padding: 6px 4px;
}
.ps-char b { font-size: 38px; line-height: 1.1; font-weight: 600; }
.ps-char small { font-size: 13px; color: var(--muted); }
.ps-char span { position: absolute; top: 2px; right: 4px; font-size: 16px; }
.ps-char.st0, .ps-char.st1, .ps-char.st2 { background: #f2fbf2; border-color: #cfe8c4; }
.ps-char.soil { background: #faf6ef; border-color: var(--line); opacity: 0.7; }

/* 👪 parent view: the kid's garden per word set */
.pv-water { margin: 0 0 8px; font-weight: 800; color: #1c64a8; }
.pv-garden { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pv-garden .pv-water { grid-column: 1 / -1; }
.pv-set {
  display: flex; flex-direction: column; gap: 4px; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 2px solid #e3d8fb; border-radius: 14px; padding: 8px 12px;
}
.pv-set.on { border-color: #8b5cf6; box-shadow: 0 0 0 3px #e3d8fb; }
.pv-set > b { font-size: 16px; }
.pv-set small { color: var(--muted); font-weight: 700; font-size: 13px; }
.pv-set small b { color: var(--ink); }
.pv-set .wilt { color: var(--accent); }
.pv-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); }
.pv-bar i { display: block; }
.pv-bar .st4 { background: #2f9e44; } .pv-bar .st3 { background: #f2b705; } .pv-bar .st2 { background: #69c46d; }
.pv-bar .st1 { background: #a8dca0; } .pv-bar .st0 { background: #c9a27e; } .pv-bar .wilt { background: #e0573e; }
.pv-bar .soil { background: #e8e0d4; }
.pv-table-title { margin: 4px 0 6px; font-size: 16px; color: var(--muted); }
.dict-py-row .dict-tools { margin-left: auto; }

/* ---------- ☁️ Family account (js/account.js) ---------- */
#home .home-head .cloud-btn { position: relative; }
.cloud-btn i { position: absolute; right: 4px; bottom: 6px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: #bbb; }
.cloud-btn i.ok { background: var(--green); }
.cloud-btn i.busy { background: #f5a623; }
.cloud-btn i.warn, .cloud-btn i.off { background: #e5484d; }
.account-card { width: min(560px, 100%); }
.account-card label { display: block; font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.account-card input {
  display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; font-size: 20px; font-weight: 700;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg);
}
.acct-lead { font-size: 18px; line-height: 1.4; margin: 0 0 16px; }
.acct-state { font-size: 18px; margin: 0 0 16px; }
.acct-msg { min-height: 1.4em; font-size: 17px; font-weight: 700; color: var(--green); margin: 4px 0 12px; }
.acct-msg.bad { color: #d23b3b; }
.acct-link { display: block; margin: 8px auto 0; font-size: 18px; min-height: 48px; }
.acct-close { margin-top: 8px; }
#acct-out-btn.pressing { background: #ffe1e1; transition: background 1s; }

/* 👩‍💻 Pilot families (js/pilot.js) */
#pilot { z-index: 31; }
.pilot-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pilot-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); font-size: 17px; }
.pilot-list li .pl-who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pilot-list li .pl-who b { display: block; }
.pilot-list li .pl-who small { color: var(--muted); }
.pilot-list li button { font: inherit; font-weight: 800; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); min-height: 44px; }
.pilot-list .pl-empty { justify-content: center; color: var(--muted); }

/* ---------- Brainrot Invasion: continue a saved run ---------- */
.inv-continue { display: block; width: 100%; margin-bottom: 10px; }
.inv-continue small { display: block; font-size: 16px; font-weight: 700; opacity: 0.9; }
.inv-continue[hidden] { display: none; }
.pause-save-note { font-size: 16px; color: var(--muted); text-align: center; margin: 4px 0 12px; }

/* ---------- 👋 Welcome for a new family (js/onboard.js) ---------- */
.sheet.onboard { z-index: 28; background: linear-gradient(160deg, #fff1d6, #ffe0ea 55%, #dff3ff); }
.onboard-card { width: min(620px, 100%); }
.ob-lead { font-size: 19px; line-height: 1.45; margin: 0 0 14px; }
.ob-foot { margin-top: 18px; }
.ob-form { width: 100%; }
.ob-kids { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ob-kids li { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border: 2px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 18px; }
.ob-kids .ob-av { font-size: 24px; }
.ob-kids button { border: 0; background: #0000000d; border-radius: 50%; width: 32px; height: 32px; }
.ob-avatars { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ob-avatar { font-size: 28px; width: 52px; height: 52px; border-radius: 16px; border: 3px solid var(--line); background: var(--bg); }
.ob-avatar.on { border-color: var(--green); background: #e6f6ee; }
.ob-sets { display: flex; flex-direction: column; gap: 10px; }
.ob-set { text-align: left; padding: 14px 16px; border-radius: 18px; border: 3px solid var(--line); background: var(--bg); }
.ob-set b { display: block; font-size: 19px; }
.ob-set small { display: block; font-size: 15px; color: var(--muted); margin-top: 4px; }
.ob-set.on { border-color: var(--green); background: #e6f6ee; }
.ob-tour { font-size: 21px; min-height: 5.5em; }
.ob-dots { display: flex; gap: 6px; justify-content: center; }
.ob-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.ob-dots i.on { background: var(--green); }
