/* =========================================================
   小学必背古诗 · 青绿山水风格
   ========================================================= */
:root {
  --bg: #FBF7EE;
  --card: #FFFFFF;
  --primary: #3BA59A;
  --primary-dark: #2C8A80;
  --primary-soft: #E2F3EF;
  --red: #E8613C;
  --red-soft: #FDEBE4;
  --yellow: #F2B544;
  --yellow-soft: #FDF2DA;
  --ink: #33415C;
  --ink-soft: #55607A;
  --muted: #8A93A6;
  --line: #EAE4D6;
  --off: #E3DDD0;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 6px 22px rgba(51, 65, 92, .08);
  --shadow-btn: 0 6px 14px rgba(44, 138, 128, .28);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "BiauKai", "Noto Serif CJK SC", "Songti SC", serif;
  --poem-size: 30px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
body[data-font="large"] { --poem-size: 36px; }
body[data-font="xlarge"] { --poem-size: 42px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.kai { font-family: var(--font-kai); }
.muted { color: var(--muted); }
.center { text-align: center; }
.accent { color: var(--red); }
.hint { font-size: 14px; color: var(--muted); margin: 10px 4px; }
.hint.warn, .warn { color: #C0582F; }
.danger { color: #C0392B !important; }

/* ---------- 页面背景与框架 ---------- */
.page-bg {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 300px;
  background: url("../images/bg-header.webp") 70% top / cover no-repeat;
  -webkit-mask-image: linear-gradient(#000 55%, transparent);
  mask-image: linear-gradient(#000 55%, transparent);
  opacity: .9;
  pointer-events: none;
  z-index: 0;
}
.is-bare .page-bg { height: 380px; }
.shell {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(96px + var(--safe-b));
}
.is-bare .shell { padding-bottom: 24px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar:empty { min-height: 8px; }
.topbar-title {
  flex: 1;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
}
.icon-btn, .icon-btn-space { width: 48px; height: 48px; flex: none; }
.icon-btn {
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .75);
  box-shadow: var(--shadow);
}
.home-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.home-user .nick { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-user + .topbar-title { flex: none; }
.topbar .fire-pill { flex: 1; justify-content: flex-end; display: flex; }

.loading { padding: 120px 0; text-align: center; color: var(--muted); }
.loading-dot {
  display: inline-block; width: 10px; height: 10px; margin-right: 8px;
  border-radius: 50%; background: var(--primary);
  animation: pulse 1s infinite alternate;
}
@keyframes pulse { to { opacity: .2; transform: scale(.6); } }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(255, 255, 255, .96);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 20px rgba(51, 65, 92, .08);
  backdrop-filter: blur(8px);
}
.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 14px;
}
.tabbar a i { width: 28px; height: 28px; }
.tabbar a.active { color: var(--primary); font-weight: 700; }
.tabbar a.active span::after {
  content: ""; display: block; height: 3px; width: 22px; margin: 1px auto 0;
  border-radius: 2px; background: var(--primary);
}

/* ---------- 图标（SVG 蒙版，颜色随文字） ---------- */
[class^="ico-"], [class*=" ico-"] {
  display: inline-block;
  width: 1.1em; height: 1.1em;
  vertical-align: -.18em;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
  flex: none;
}
.ico-home { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 11.2 12 3.5l9 7.7V20a1.5 1.5 0 0 1-1.5 1.5H15v-6.2H9v6.2H4.5A1.5 1.5 0 0 1 3 20z'/></svg>"); }
.ico-poems, .ico-book { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M2.5 5.2C5.6 3.8 8.6 3.9 11.2 5.6v15c-2.6-1.6-5.6-1.7-8.7-.4zM21.5 5.2c-3.1-1.4-6.1-1.3-8.7.4v15c2.6-1.6 5.6-1.7 8.7-.4z'/></svg>"); }
.ico-game { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M7 6.5h10a5.5 5.5 0 0 1 5.5 5.5v1.5a4 4 0 0 1-7.2 2.4L14.5 15h-5l-.8.9A4 4 0 0 1 1.5 13.5V12A5.5 5.5 0 0 1 7 6.5zM6.2 9.5v1.8H4.4v1.6h1.8v1.8h1.6v-1.8h1.8v-1.6H7.8V9.5zM16.5 10a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4zm2.3 2.3a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4z'/></svg>"); }
.ico-me { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='7.8' r='4.6'/><path d='M3 21.5c0-4.8 4-8 9-8s9 3.2 9 8z'/></svg>"); }
.ico-back { width: 24px; height: 24px; --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M15 4 7 12l8 8' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.ico-arrow { width: .9em; height: .9em; margin-left: 4px; --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m9 4 8 8-8 8' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.ico-play { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 4.2v15.6c0 .8.9 1.3 1.6.8l11.5-7.8a1 1 0 0 0 0-1.6L8.6 3.4C7.9 2.9 7 3.4 7 4.2z'/></svg>"); }
.ico-stop { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='5.5' y='5.5' width='13' height='13' rx='2.5'/></svg>"); }
.ico-fire { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12.5 1.8s5.8 4.6 5.8 11.2a6.3 6.3 0 0 1-12.6 0c0-3.3 2-5.4 2-5.4s.4 3 2.6 3.3C10.300 7 12.5 4.800 12.5 1.8z'/></svg>"); }
.ico-check { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m4.5 12.5 5 5L19.5 7' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.ico-check-circle { width: 1.3em; height: 1.3em; margin-right: 8px; --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M12 1.5a10.5 10.5 0 1 1 0 21 10.5 10.5 0 0 1 0-21zm4.6 6.4-6 6.3-3-3-1.7 1.7 4.7 4.7 7.7-8z'/></svg>"); }
.ico-lock { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='4.5' y='10' width='15' height='11.5' rx='2.5'/><path d='M8 10.5V7.5a4 4 0 0 1 8 0v3' fill='none' stroke='black' stroke-width='2.6'/></svg>"); }
.ico-leaf { color: var(--primary); --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3.5 20.5C3.5 10.500 9.500 3.500 21 3.500c0 11.500-7 17-17.500 17z'/></svg>"); }
.ico-hill { color: var(--primary); --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M1.5 20.5 8.5 8l4.200 6.500L16 10l6.500 10.500z'/></svg>"); }
.ico-pen { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3.5 20.5 4.600 15 15.600 4a2.100 2.100 0 0 1 3 0l1.400 1.400a2.100 2.100 0 0 1 0 3L9 19.400z'/></svg>"); }

/* ---------- 通用组件 ---------- */
.card {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: transform .12s, box-shadow .12s, opacity .12s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #47B5A9, var(--primary-dark));
  box-shadow: var(--shadow-btn);
}
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-danger { background: var(--red); color: #fff; }
.btn-soft-yellow { background: var(--yellow-soft); color: #B9802A; border: 2px solid #F6DFAE; }
.btn-soft-red { background: var(--red-soft); color: #D4552F; border: 2px solid #F8D3C6; }
.btn-text { background: none; color: var(--muted); font-weight: 500; font-size: 15px; min-height: 44px; padding: 0 8px; }
.btn-sm { min-height: 44px; padding: 0 18px; font-size: 16px; }
.btn-xl { min-height: 64px; font-size: 22px; letter-spacing: 3px; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 12px; margin: 14px 0; }
.btn-row > .btn { flex: 1; }
.btn-xl .ico-arrow { width: 1em; height: 1em; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  min-height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  box-shadow: var(--shadow);
  font-weight: 600;
  white-space: nowrap;
}
.fire-pill { flex: none !important; color: var(--red); background: #FFF4EC; font-size: 16px; }
.fire-pill b { font-size: 24px; line-height: 1; }
.fire-pill i { width: 22px; height: 22px; background: linear-gradient(#F7B53E, #E8613C); }
.fire-pill.is-off { color: var(--muted); background: #fff; }
.fire-pill.is-off i { background: var(--off); }

.bar { height: 10px; border-radius: 999px; background: #ECE8DF; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4BB8AB, var(--primary-dark)); transition: width .5s; }
.bar-lg { height: 16px; }

.input {
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: #FDFBF6;
  font-size: 18px;
  outline: none;
}
.input:focus { border-color: var(--primary); background: #fff; }

.switch {
  appearance: none; -webkit-appearance: none;
  position: relative;
  width: 60px; height: 34px;
  margin: 0;
  border-radius: 999px;
  background: var(--off);
  transition: background .2s;
  flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  transition: transform .2s;
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(26px); }
.switch-label { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; cursor: pointer; }

.sec-title { display: flex; align-items: center; gap: 8px; font-size: 20px; margin-bottom: 12px; }
.sec-title i { width: 22px; height: 22px; }
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 12px;
  font-size: 22px;
}
.sec-head span { padding-left: 12px; border-left: 5px solid var(--primary); line-height: 1.1; }
.sec-head em, .sec-head a { font-style: normal; font-size: 15px; color: var(--muted); font-weight: 500; display: flex; align-items: center; min-height: 44px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-sm { min-height: 38px; padding: 0 14px; font-size: 15px; }
.chips-sub .chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* 头像 */
.avatar {
  position: relative;
  display: inline-grid; place-items: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary-soft);
  overflow: hidden;
  flex: none;
}
.avatar em { font-style: normal; font-size: 2.1em; line-height: 1; }
.avatar img { position: absolute; inset: -2%; width: 104%; height: 104%; object-fit: cover; }
.avatar.sm { width: 44px; height: 44px; font-size: 12px; }
.avatar.md { width: 56px; height: 56px; font-size: 14px; border: 3px solid #fff; box-shadow: var(--shadow); }
.avatar.lg { width: 84px; height: 84px; font-size: 22px; border: 4px solid #fff; box-shadow: var(--shadow); }

/* 星级（朱红印章星） */
.stars { display: inline-flex; gap: 3px; vertical-align: middle; }
.seal-star {
  width: 20px; height: 20px;
  background: var(--off);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8a1.300 1.300 0 0 1 1.200.8l2.400 5 5.400.7a1.300 1.300 0 0 1 .700 2.300l-4 3.700 1 5.400a1.300 1.300 0 0 1-1.900 1.400L12 18.500l-4.800 2.600a1.300 1.300 0 0 1-1.900-1.400l1-5.400-4-3.700a1.300 1.300 0 0 1 .700-2.300l5.400-.7 2.400-5A1.300 1.300 0 0 1 12 1.800z'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8a1.300 1.300 0 0 1 1.200.8l2.400 5 5.400.7a1.300 1.300 0 0 1 .700 2.300l-4 3.700 1 5.400a1.300 1.300 0 0 1-1.900 1.400L12 18.500l-4.800 2.600a1.300 1.300 0 0 1-1.900-1.400l1-5.400-4-3.700a1.300 1.300 0 0 1 .700-2.300l5.400-.7 2.400-5A1.300 1.300 0 0 1 12 1.800z'/></svg>") center / contain no-repeat;
}
.seal-star.on { background: linear-gradient(160deg, #F07A50, #D9472A); }
.stars.big { gap: 6px; }
.stars.big .seal-star { width: 40px; height: 40px; }

/* 段位印章 */
.rank-seal {
  flex: none;
  display: grid; place-items: center;
  width: 64px; min-height: 104px;
  padding: 8px 6px;
  border: 3px solid #fff;
  outline: 3px solid var(--red);
  border-radius: 12px;
  background: linear-gradient(160deg, #EE7550, #D9472A);
  color: #fff;
  font-family: var(--font-kai);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  writing-mode: vertical-rl;
  letter-spacing: 4px;
  box-shadow: 0 6px 16px rgba(217, 71, 42, .3);
  transform: rotate(-3deg);
}
.rank-seal.big { margin: 4px auto 14px; width: 84px; min-height: 140px; font-size: 44px; }

/* 提示条 */
.toast-box {
  position: fixed; left: 0; right: 0; top: calc(16px + env(safe-area-inset-top, 0px));
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast, .inline-toast {
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(51, 65, 92, .94);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  animation: toast-in .25s ease-out;
  transition: opacity .35s, transform .35s;
}
.toast.ok, .inline-toast.ok { background: var(--primary-dark); }
.toast.warn, .inline-toast.warn { background: #D4552F; }
.toast.out, .inline-toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
.inline-toast {
  position: fixed; left: 50%; top: 40%;
  transform: translateX(-50%);
  z-index: 90;
  text-align: center;
  white-space: nowrap;
}
.inline-toast.out { transform: translate(-50%, -10px); }

/* 弹窗 */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(40, 48, 66, .45);
  opacity: 0;
  transition: opacity .2s;
}
.modal-wrap.show { opacity: 1; }
.modal {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  padding: 24px 20px 18px;
  border-radius: 26px;
  background: var(--bg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
  transform: scale(.92);
  transition: transform .2s;
}
.modal-wrap.show .modal { transform: none; }
.modal-title { font-size: 22px; text-align: center; margin-bottom: 12px; }
.modal-text { font-size: 18px; margin: 6px 0 16px; line-height: 1.7; }
.modal .input { margin-bottom: 12px; }
.note-title { font-size: 34px; color: var(--primary-dark); text-align: center; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; resize: none; }
.preview-box { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius-sm); background: var(--primary-soft); margin-bottom: 6px; }

.celebrate { text-align: center; position: relative; }
.celebrate h2 { font-size: 30px; margin: 12px 0 6px; color: var(--red); }
.celebrate p { font-size: 17px; margin-bottom: 8px; }
.celebrate .btn { margin-top: 16px; }
.celebrate .stars { margin-top: 10px; }
.celebrate .seal-star.on { animation: pop .5s backwards; }
.celebrate .seal-star.on:nth-child(2) { animation-delay: .08s; }
.celebrate .seal-star.on:nth-child(3) { animation-delay: .16s; }
.celebrate .seal-star.on:nth-child(4) { animation-delay: .24s; }
.celebrate .seal-star.on:nth-child(5) { animation-delay: .32s; }
.burst {
  position: absolute; left: 50%; top: 30px; width: 220px; height: 220px; margin-left: -110px; margin-top: -80px;
  background: repeating-conic-gradient(rgba(242, 181, 68, .22) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%;
  animation: spin 8s linear infinite;
  z-index: -1;
}
@keyframes pop { from { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.3); } }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-card { text-align: center; color: var(--ink-soft); padding: 24px 18px; }
.empty-card .btn { margin-top: 14px; }
.load-error { margin-top: 60px; }
.load-error h2 { margin-bottom: 10px; }
.load-error pre { background: var(--bg); padding: 10px; border-radius: 10px; overflow-x: auto; }

/* ---------- 首次进入 ---------- */
.welcome-hero { position: relative; display: flex; align-items: center; min-height: 230px; margin: 0 -16px 8px; padding: 0 16px; }
.hero-mascot { width: 46%; max-width: 230px; margin-left: -8px; filter: drop-shadow(0 6px 10px rgba(51, 65, 92, .12)); mix-blend-mode: multiply; }
.hero-text { flex: 1; padding-left: 4px; }
.hero-text h1 { font-size: clamp(38px, 11vw, 56px); line-height: 1.15; }
.hero-text p { margin-top: 10px; font-size: clamp(12px, 3.6vw, 16px); color: var(--ink-soft); white-space: nowrap; }
.form-card .sec-title { font-size: 20px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.avatar-pick {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 0;
  border: 0; background: none;
  font-size: 15px; font-weight: 600;
}
.avatar-pick .avatar { width: min(72px, 18vw); height: min(72px, 18vw); font-size: 15px; border: 3px solid transparent; transition: transform .15s; }
.avatar-pick.selected .avatar { border-color: var(--primary); transform: scale(1.05); box-shadow: 0 0 0 3px var(--primary-soft); }
.avatar-pick.selected::after {
  content: ""; position: absolute; top: 0; right: 6%;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff;
  background: var(--primary) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m5 12.500 4.500 4.500L19 7.500' fill='none' stroke='white' stroke-width='3.400' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 70% no-repeat;
}
.avatar-grid.sm { margin-bottom: 12px; }
.avatar-grid.sm .avatar { width: 56px; height: 56px; }
.grade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade-grid.sm { margin-bottom: 6px; }
.grade-btn {
  position: relative;
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #FAF8F3;
  font-size: 18px; font-weight: 700;
}
.grade-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-btn); }
#start { margin-top: 6px; }
.welcome-foot {
  height: 130px; margin: 6px -16px 0;
  background: url("../images/bg-footer.webp") center bottom / cover no-repeat;
  -webkit-mask-image: linear-gradient(transparent, #000 45%);
  mask-image: linear-gradient(transparent, #000 45%);
}

/* ---------- 首页 ---------- */
.rank-card {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  min-height: 170px;
  padding: 20px 20px 20px 22px;
  overflow: hidden;
  background: linear-gradient(115deg, #fff 55%, rgba(255, 255, 255, .7)), url("../images/bg-header.webp") center / cover;
}
.rank-body { flex: 1; position: relative; z-index: 1; min-width: 0; padding-right: 84px; }
.rank-text { font-size: clamp(13px, 3.8vw, 15px); font-weight: 600; margin-bottom: 10px; line-height: 1.7; white-space: nowrap; }
.rank-text b { font-size: 20px; color: var(--primary-dark); margin: 0 2px; }
.rank-num { text-align: center; color: var(--primary-dark); font-weight: 700; margin-top: 4px; }
.rank-mascot {
  position: absolute; right: -6px; bottom: -6px;
  height: 88%; max-height: 170px; width: auto;
  mix-blend-mode: multiply;
}

.poem-row { display: flex; align-items: center; gap: 14px; padding: 12px; }
.thumb { width: 92px; height: 80px; border-radius: 14px; object-fit: cover; flex: none; background: var(--primary-soft); }
.poem-row-body { flex: 1; min-width: 0; }
.poem-row h4, .poem-item h4 { font-size: 22px; line-height: 1.3; }
.poem-row .muted { font-size: 14px; }
.line1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.poem-row .btn { flex: none; padding: 0 14px; }

.rec-card { position: relative; padding: 0; overflow: hidden; min-height: 200px; }
.rec-img {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 58%; height: 100%; object-fit: cover;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%);
  mask-image: linear-gradient(90deg, transparent, #000 45%);
}
.rec-body { position: relative; padding: 20px; max-width: 66%; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.rec-body h4 { font-size: 26px; }
.rec-lines { font-size: 17px; line-height: 1.8; color: var(--ink-soft); }
.rec-body .btn { margin-top: 6px; }

/* ---------- 列表 ---------- */
.list-count { font-size: 14px; margin: 4px 4px 10px; }
.poem-list { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.poem-item { display: flex; align-items: center; gap: 14px; padding: 12px; }
.poem-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.poem-item .muted { font-size: 14px; }
.grade-tag { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; }

/* ---------- 诗词详情 ---------- */
.seg-tabs {
  display: flex;
  max-width: 420px;
  margin: 0 auto 12px;
  padding: 5px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
}
.seg-tab {
  flex: 1;
  display: grid; place-items: center;
  min-height: 50px;
  border-radius: 999px;
  font-size: 22px; font-weight: 700;
  color: var(--ink-soft);
}
.seg-tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-btn); }
.poem-status { display: flex; align-items: center; justify-content: center; gap: 8px; width: fit-content; margin: 0 auto 12px; padding: 4px 14px; border-radius: 999px; background: rgba(255, 255, 255, .85); font-size: 14px; }

.poem-card { position: relative; text-align: center; padding: 22px 14px 18px; overflow: hidden; }
.poem-title { font-size: calc(var(--poem-size) * .95); line-height: 1.3; }
.poem-title.is-long { font-size: min(calc(var(--poem-size) * .78), calc((min(100vw, 720px) - 84px) / (var(--tlen, 10) + 2))); }
.poem-title.is-long.with-py { flex-wrap: nowrap; font-size: min(calc(var(--poem-size) * .78), calc((min(100vw, 720px) - 84px) / (var(--tlen, 10) * 1.2 + 1.6))); }
.poem-title.is-long.with-py .zi { min-width: 1.18em; }
.poem-title.with-py .bk { flex: none; width: .7em; }
.poem-title.with-py { display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.poem-title.with-py .zi { font-size: 1em; }
.poem-title .bk { padding-bottom: .05em; }
.poem-subtitle { font-size: 16px; color: var(--ink-soft); margin-top: 2px; }
.poem-author { font-size: 17px; color: var(--ink-soft); margin: 4px 0 14px; letter-spacing: 2px; }
.seg-title { border-radius: 16px; padding: 4px 0; transition: background .2s; }
.seg-title.is-reading { background: var(--primary-soft); }

.poem-lines {
  position: relative; z-index: 1;
  font-family: var(--font-kai);
  font-size: min(var(--poem-size), calc((min(100vw, 720px) - 76px) / 9.6));
}
.poem-line { display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; margin: .2em 0; line-height: 1.25; }
.poem-line.plain { display: block; margin: .25em 0; }
.seg { display: inline-flex; align-items: flex-end; border-radius: .25em; padding: 0 .05em; transition: background .2s, transform .2s, color .2s; }
.seg.is-reading { background: var(--primary-soft); color: var(--primary-dark); transform: scale(1.06); }
.zi { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.32em; }
.zi .py { font-family: var(--font); font-style: normal; font-size: .36em; line-height: 1.3; color: var(--ink-soft); white-space: nowrap; letter-spacing: 0; }
.seg.is-reading .py { color: var(--primary-dark); }
.zi b { font-weight: 700; }
.pc { display: inline-block; width: .55em; text-align: left; font-weight: 700; }
.has-py .poem-line { margin: .35em 0; }
.poem-art {
  width: calc(100% + 28px);
  max-width: none;
  margin: -6px -14px -18px;
  height: clamp(130px, 32vw, 220px);
  object-fit: cover;
  object-position: center 60%;
  -webkit-mask-image: linear-gradient(transparent, #000 35%);
  mask-image: linear-gradient(transparent, #000 35%);
}

.speed-switch {
  display: flex; max-width: 400px; margin: 16px auto 8px;
  padding: 5px; border-radius: 999px; background: #fff; box-shadow: var(--shadow);
}
.speed-btn { flex: 1; min-height: 48px; border: 0; border-radius: 999px; background: none; font-size: 18px; font-weight: 600; color: var(--ink-soft); }
.speed-btn.active { background: var(--primary); color: #fff; }
.play-row { display: flex; align-items: center; justify-content: space-between; max-width: 420px; margin: 8px auto 0; }
.play-side { flex: 1; display: flex; justify-content: flex-end; }
.play-btn {
  display: grid; place-items: center;
  width: 92px; height: 92px;
  margin: 0 16px;
  border: 6px solid #fff;
  border-radius: 50%;
  background: linear-gradient(160deg, #4CBBAE, var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 24px rgba(44, 138, 128, .35);
  transition: transform .15s;
}
.play-btn i { width: 40px; height: 40px; margin-left: 4px; }
.play-btn.playing { background: linear-gradient(160deg, #F07A50, #D9472A); box-shadow: 0 10px 24px rgba(217, 71, 42, .3); animation: breathe 1.6s ease-in-out infinite; }
.play-btn.playing i { margin-left: 0; width: 34px; height: 34px; }
.play-btn:active { transform: scale(.94); }
.play-btn:disabled { opacity: .4; }
@keyframes breathe { 50% { box-shadow: 0 10px 34px rgba(217, 71, 42, .5), 0 0 0 10px rgba(232, 97, 60, .12); } }

.voice-tag { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 600; }

/* 懂 */
.note-word {
  border: 0; padding: 0 .02em; margin: 0;
  background: linear-gradient(transparent 70%, rgba(242, 181, 68, .45) 70%);
  border-bottom: 2px dashed var(--yellow);
  font: inherit; color: inherit;
  cursor: pointer;
}
.info-card p { font-size: 17px; line-height: 1.85; }
.notes { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: baseline; }
.notes dt { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.notes dd { margin: 0; font-size: 16px; }

/* 背 */
.fade-steps { display: flex; gap: 6px; margin-bottom: 10px; }
.fade-step {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 74px;
  padding: 8px 2px 6px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700;
  color: var(--ink-soft);
}
.fade-step .badge {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 16px;
}
.fade-step .badge i { width: 16px; height: 16px; }
.fade-step.done .badge { background: var(--primary); color: #fff; }
.fade-step.open .badge { background: var(--red); color: #fff; }
.fade-step.locked { background: #F1EEE7; box-shadow: none; color: var(--muted); }
.fade-step.locked .badge { background: #E2DED4; color: #A7A196; }
.fade-step.current { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-3px); }
.fade-step .name { white-space: nowrap; }
.level-desc { font-size: 15px; color: var(--ink-soft); margin: 4px 4px 12px; }
.level-desc b { color: var(--primary-dark); }

.recite-card .poem-lines { font-size: min(var(--poem-size), calc((min(100vw, 720px) - 76px) / 9)); }
.poem-line.recite { gap: .14em; margin: .3em 0; align-items: center; }
.tian {
  display: inline-grid; place-items: center;
  width: 1.2em; height: 1.2em;
  border: 2px solid #C9D3D6;
  border-radius: 4px;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), rgba(201, 211, 214, .7) calc(50% - .5px), rgba(201, 211, 214, .7) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), rgba(201, 211, 214, .7) calc(50% - .5px), rgba(201, 211, 214, .7) calc(50% + .5px), transparent calc(50% + .5px)),
    #FDFCF9;
  font-weight: 700;
  line-height: 1;
}
.tian.show { border-color: transparent; background: none; }
.tian.revealed { color: var(--red); animation: fade-in .3s; }
.tian.sm { line-height: 1; width: .9em; height: .9em; vertical-align: -.05em; margin: 0 .05em; }
.recite .pc { width: .45em; }
@keyframes fade-in { from { opacity: 0; } }
.quiz-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 10px; font-size: 20px; font-weight: 700; }
.quiz-retry { text-align: center; margin-top: 14px; }
.quiz-retry p { font-size: 17px; margin-bottom: 10px; }

.review-info h2 { font-size: 26px; margin-bottom: 6px; }

/* ---------- 游戏 ---------- */
.games-home > .muted { margin: 4px 0 14px; }
.game-entry { display: flex; align-items: center; gap: 16px; padding: 20px; min-height: 120px; transition: transform .15s; }
.game-entry:active { transform: scale(.98); }
.game-entry.disabled { opacity: .5; pointer-events: none; }
.game-entry h3 { font-size: 26px; margin-bottom: 4px; }
.game-ico {
  flex: none;
  display: grid; place-items: center;
  width: 76px; height: 76px;
  border-radius: 20px;
  color: #fff;
  font-family: var(--font-kai);
  font-size: 40px; font-weight: 700;
  box-shadow: var(--shadow-btn);
}
.game-ico::after { content: attr(data-ico); }
.game-ico.tone-teal { background: linear-gradient(160deg, #4CBBAE, var(--primary-dark)); }
.game-ico.tone-red { background: linear-gradient(160deg, #F07A50, #D9472A); box-shadow: 0 6px 14px rgba(217, 71, 42, .28); }
.game-ico.tone-yellow { background: linear-gradient(160deg, #F7C860, #E39A1F); box-shadow: 0 6px 14px rgba(227, 154, 31, .3); }
.game-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.game-entry { position: relative; }
.game-entry.is-new::after {
  content: "新"; position: absolute; top: 10px; right: 12px;
  padding: 0 8px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 700; line-height: 22px;
}

.game-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.score-pill { color: var(--ink-soft); }
.score-pill b { color: var(--red); font-size: 22px; }
.star-ico { width: 22px; height: 22px; background: linear-gradient(#F7C548, #EFA21F); -webkit-mask: inherit; }
.score-pill .star-ico {
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l3 6.300 7 .900-5.100 4.800 1.300 6.900L12 17.600 5.800 20.900l1.300-6.900L2 9.200l7-.9z'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l3 6.300 7 .900-5.100 4.800 1.300 6.900L12 17.600 5.800 20.900l1.300-6.900L2 9.200l7-.9z'/></svg>") center / contain no-repeat;
}
.progress-pill { flex-direction: column; align-items: stretch; gap: 4px; min-width: 130px; font-size: 14px; color: var(--ink-soft); padding: 6px 16px; }
.progress-pill .bar { height: 8px; }
.game-poem-title { text-align: center; margin: 6px 0 12px; }
.game-poem-title h2 { font-size: 32px; }
.game-poem-title p { font-size: 17px; color: var(--ink-soft); letter-spacing: 2px; }

.order-slots { padding: 14px; }
.order-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.order-num {
  flex: none;
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; font-size: 18px;
}
.order-num.is-filled { background: var(--primary); color: #fff; }
.order-slot { flex: 1; min-height: 62px; border-radius: 16px; }
.order-slot.is-empty { border: 2px dashed #A9D8D0; background: #F8FCFB; }
.order-slot.is-drop { border-color: var(--red); background: var(--red-soft); }
.order-card {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 62px;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: clamp(22px, 6.4vw, 28px);
  font-weight: 700;
  letter-spacing: 2px;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
.order-slot.order-card { background: var(--primary-soft); border: 2px solid #9ED3CA; }
.order-slot.order-card.is-right { background: #DDF3E6; border-color: #5BBE86; }
.order-slot.order-card.is-wrong { background: var(--red-soft); border-color: var(--red); animation: shake .4s; }
.order-tip { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 10px; color: var(--ink-soft); font-size: 15px; font-weight: 600; text-align: center; }
.order-tip .leaf { width: 14px; height: 8px; border-radius: 50% 0; background: #8FCFC4; flex: none; }
.order-pool { min-height: 80px; }
.pool-card { justify-content: space-between; margin-bottom: 12px; background: #fff; box-shadow: var(--shadow); }
.pool-card .grip {
  flex: none; width: 14px; height: 24px; opacity: .45;
  background-image: radial-gradient(circle, var(--ink) 2px, transparent 2.5px);
  background-size: 7px 8px;
}
.order-card.is-dragging { opacity: .35; }
.order-pool-empty { text-align: center; color: var(--muted); padding: 20px 0; }
.drag-ghost {
  position: fixed !important; z-index: 120; margin: 0 !important;
  pointer-events: none;
  background: #fff;
  box-shadow: 0 14px 30px rgba(51, 65, 92, .25);
  opacity: .96;
}
.order-submit { margin-top: 4px; }
.order-game.is-solved .order-slots { animation: glow 1s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(91, 190, 134, .35); } }

.fill-progress { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 600; color: var(--ink-soft); }
.fill-card { text-align: center; padding: 22px 16px; }
.fill-source { font-size: 18px; color: var(--ink-soft); }
.fill-line { line-height: 1.2; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .08em; margin: 18px 0 10px; font-size: min(42px, calc((min(100vw, 720px) - 80px) / 8.4)); font-weight: 700; }
.fill-blank {
  display: inline-grid; place-items: center;
  width: 1.2em; height: 1.2em;
  line-height: 1; box-sizing: border-box;
  border: 3px dashed var(--red);
  border-radius: 10px;
  background: var(--red-soft);
}
.fill-blank.is-revealed { border-style: solid; color: var(--red); animation: pop .35s; }
.fill-ask { color: var(--muted); margin-bottom: 14px; }
.fill-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fill-opt {
  min-height: 76px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #FDFBF6;
  font-size: 38px; font-weight: 700;
  transition: transform .12s;
}
.fill-opt:active:not(:disabled) { transform: scale(.95); }
.fill-opt.is-right { background: #DDF3E6; border-color: #5BBE86; color: #2D8A57; }
.fill-opt.is-wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); animation: shake .4s; }
.fill-opt:disabled:not(.is-right):not(.is-wrong) { opacity: .5; }
.fill-feedback { margin-top: 14px; }
.fill-feedback p { font-size: 17px; margin-bottom: 12px; }
.fb-ok { color: #2D8A57; font-weight: 700; font-size: 20px !important; }
.fb-bad { color: #C0582F; }

.game-result { text-align: center; padding: 28px 18px; }
.game-result h2 { font-size: 30px; }
.result-stars { display: flex; justify-content: center; gap: 10px; margin: 16px 0; }
.result-stars .seal-star { width: 48px; height: 48px; }
.result-stars .seal-star.on { animation: pop .5s backwards; }
.result-stars .seal-star:nth-child(2) { animation-delay: .1s; }
.result-stars .seal-star:nth-child(3) { animation-delay: .2s; }
.result-score { font-size: 20px; }
.result-score b { font-size: 40px; color: var(--red); margin-left: 6px; }

/* ---------- 新游戏：通用 ---------- */
.combo-bar { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; }
.combo { flex: none; padding: 4px 12px; border-radius: 999px; background: #F1EEE7; color: var(--muted); font-weight: 700; font-size: 15px; }
.combo b { font-size: 18px; }
.combo.on { background: var(--red-soft); color: var(--red); }
.combo.bump { animation: bump .3s; }
.timer { flex: 1; height: 12px; border-radius: 999px; background: #ECE8DF; overflow: hidden; }
.timer i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #F2B544, #EFA21F); transition: width 1s linear; }
.timer.urgent i { background: linear-gradient(90deg, #F07A50, #D9472A); }
.timer.urgent { animation: pulse-bar .6s infinite alternate; }
.timer-num { flex: none; width: 32px; text-align: right; font-weight: 700; font-size: 18px; color: var(--ink-soft); }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes pulse-bar { to { opacity: .6; } }
.shake { animation: shake .4s; }

/* 字块拼诗句 */
.pinju-card { text-align: center; }
.pinju-card.is-done { animation: glow 1s; }
.pinju-src { font-size: 16px; color: var(--ink-soft); }
.pinju-prev { font-size: 20px; color: var(--muted); margin: 6px 0 10px; }
.pinju-slots { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px; font-size: min(36px, calc((min(100vw, 720px) - 100px) / 8.6)); font-weight: 700; }
.pinju-slot {
  display: inline-grid; place-items: center;
  width: 1.25em; height: 1.25em;
  line-height: 1; box-sizing: border-box;
  border: 2px dashed #A9D8D0; border-radius: 10px; background: #F8FCFB;
}
.pinju-slot.filled { border: 2px solid var(--primary); background: var(--primary-soft); color: var(--primary-dark); animation: pop .3s; }
.pinju-slot.missed { border: 2px solid var(--red); background: var(--red-soft); color: var(--red); }
.pinju-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.pinju-tile {
  aspect-ratio: 1;
  border: 0; border-radius: 16px;
  background: #fff; box-shadow: 0 4px 0 #E3DDD0, var(--shadow);
  font-size: 32px; font-weight: 700;
  animation: drop-in .35s backwards;
  transition: transform .1s, opacity .25s;
}
.pinju-tile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #E3DDD0; }
.pinju-tile.used { opacity: 0; transform: scale(.4); pointer-events: none; }
.pinju-tile.shake { background: var(--red-soft); color: var(--red); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-14px) scale(.8); } }

/* 上下句配对（翻牌） */
.pair-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; perspective: 900px; }
.pair-grid.many { grid-template-columns: repeat(3, 1fr); }
.pair-card { position: relative; height: 104px; padding: 0; border: 0; background: none; }
.pair-inner { position: absolute; inset: 0; transition: transform .45s; transform-style: preserve-3d; }
.pair-card.flipped .pair-inner { transform: rotateY(180deg); }
.pair-back, .pair-front {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.pair-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .25) 0 30%, transparent 31%),
    linear-gradient(160deg, #4CBBAE, var(--primary-dark));
  border: 3px solid #fff;
}
.pair-back b { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 10px; background: var(--red); color: #fff; font-size: 26px; transform: rotate(-6deg); }
.pair-front { background: #fff; transform: rotateY(180deg); padding: 6px; border: 2px solid var(--line); }
.pair-front em { font-style: normal; font-size: 12px; padding: 0 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-dark); }
.pair-front span { font-size: clamp(15px, 4.4vw, 20px); font-weight: 700; line-height: 1.3; }
.pair-card.miss .pair-front { border-color: var(--red); background: var(--red-soft); }
.pair-card.matched .pair-front { border-color: #5BBE86; background: #DDF3E6; }
.pair-card.matched { animation: matched .6s forwards .1s; pointer-events: none; }
@keyframes matched { 40% { transform: scale(1.08); } to { transform: scale(.92); opacity: .35; } }

/* 飞花令 */
.feihua-key { display: flex; align-items: center; gap: 14px; margin: 0 2px 12px; }
.feihua-key p.kai { font-size: 20px; font-weight: 700; }
.feihua-key .muted { font-size: 14px; }
.seal-char {
  flex: none; display: grid; place-items: center;
  width: 72px; height: 72px; border-radius: 14px;
  background: linear-gradient(160deg, #EE7550, #D9472A); color: #fff;
  font-size: 44px; font-weight: 700;
  border: 3px solid #fff; outline: 3px solid var(--red);
  transform: rotate(-4deg);
  animation: pop .45s;
}
.feihua-list { display: grid; gap: 10px; }
.feihua-line {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0;
  min-height: 60px; padding: 8px 16px;
  border: 2px solid transparent; border-radius: 16px;
  background: #fff; box-shadow: var(--shadow);
  font-size: clamp(20px, 5.8vw, 26px); font-weight: 700; text-align: left;
  animation: drop-in .3s backwards;
}
.feihua-line:nth-child(2) { animation-delay: .05s; } .feihua-line:nth-child(3) { animation-delay: .1s; }
.feihua-line:nth-child(4) { animation-delay: .15s; } .feihua-line:nth-child(5) { animation-delay: .2s; }
.feihua-line:nth-child(6) { animation-delay: .25s; }
.feihua-line em { font-family: var(--font); font-style: normal; font-size: 12px; color: var(--muted); font-weight: 500; }
.feihua-line mark { background: none; color: var(--red); text-decoration: underline wavy var(--red); text-underline-offset: 5px; }
.feihua-line.is-right { border-color: #5BBE86; background: #DDF3E6; }
.feihua-line.is-wrong { border-color: var(--red); background: var(--red-soft); animation: shake .4s; opacity: .7; }
.feihua-line.is-missed { border-color: var(--yellow); background: var(--yellow-soft); }

/* ---------- 每日闯关 + 吉祥物 ---------- */
.quest-card { padding: 16px 14px 18px; background: linear-gradient(180deg, #F6FBF9, #fff 60%); }
.quest-head { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.mascot-btn { flex: none; width: 84px; height: 84px; padding: 0; border: 0; background: none; }
.mascot-btn img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; }
.mascot-btn.hop { animation: hop .5s; }
@keyframes hop { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
.bubble {
  position: relative; flex: 1;
  margin-bottom: 18px; padding: 10px 14px;
  border-radius: 16px; border: 2px solid var(--primary-soft);
  background: #fff; font-size: 15px; line-height: 1.6;
  box-shadow: var(--shadow);
}
.bubble::before {
  content: ""; position: absolute; left: -9px; bottom: 14px;
  border: 8px solid transparent; border-right-color: #fff; border-left: 0;
  filter: drop-shadow(-2px 0 0 var(--primary-soft));
}
.bubble.pop { animation: bubble-pop .35s; }
@keyframes bubble-pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.quest-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 10px; font-size: 20px; font-weight: 700; }
.quest-title em { font-style: normal; font-size: 15px; color: var(--primary-dark); }
.quest-map { position: relative; display: flex; justify-content: space-between; padding: 0 2px; }
.quest-map::before {
  content: ""; position: absolute; left: 30px; right: 30px; top: 27px;
  border-top: 3px dashed #CFE6E1;
}
.q-node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 20%; padding: 0; border: 0; background: none;
  font: inherit; color: inherit;
}
.q-node:nth-child(even) { transform: translateY(10px); }
.q-dot {
  display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 50%;
  background: #fff; border: 3px solid #CFE6E1;
  color: var(--primary-dark); font-size: 24px;
  box-shadow: var(--shadow);
  transition: transform .2s;
}
.q-dot b { font-size: 24px; }
a.q-node .q-dot { border-color: var(--primary); animation: beckon 1.8s ease-in-out infinite; }
a.q-node:active .q-dot { transform: scale(.92); }
.q-node.done .q-dot { background: var(--primary); border-color: var(--primary); color: #fff; animation: none; }
.q-node.done .q-dot i { width: 26px; height: 26px; }
.q-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.q-node.done .q-label { color: var(--primary-dark); }
.q-node.chest .q-dot { font-size: 28px; background: #FFF7E6; border-color: #F6DFAE; }
.q-node.chest:disabled { opacity: 1; cursor: default; }
.q-node.chest:disabled:not(.done) .q-dot { filter: grayscale(.8); opacity: .7; }
.q-node.chest.ready .q-dot { border-color: var(--yellow); animation: chest-shake 1.2s ease-in-out infinite; box-shadow: 0 0 0 6px rgba(242, 181, 68, .25); }
.q-node.chest.done .q-dot { background: var(--yellow-soft); border-color: var(--yellow); }
@keyframes beckon { 50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(59, 165, 154, .15); } }
@keyframes chest-shake { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-10deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-6deg); } }

.rank-mascot { cursor: pointer; }
.rank-mascot.wiggle { animation: wiggle .6s; transform-origin: bottom center; }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }
.celebrate-mascot { width: 96px; margin: -8px auto 4px; animation: hop .7s .2s; }
.chest-big { font-size: 72px; line-height: 1; animation: pop .6s; }
.chest-quote { font-size: 22px; color: var(--primary-dark); margin-top: 12px !important; }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 150; pointer-events: none; }

/* ---------- 我的 ---------- */
.me-card { display: flex; align-items: center; gap: 16px; }
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.me-info h2 { font-size: 24px; word-break: break-all; }
.me-card .rank-seal { width: 56px; min-height: 92px; font-size: 26px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 12px 4px; border-radius: 16px; background: #FAF7F0; text-align: center; }
.stat b { font-size: 26px; color: var(--primary-dark); line-height: 1.3; }
.stat span { font-size: 13px; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 600; }
.set-row:last-of-type { border-bottom: 0; }
.mini-seg { display: flex; padding: 4px; border-radius: 999px; background: #F3EFE6; }
.mini-seg button { min-width: 56px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 999px; background: none; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.mini-seg button.active { background: var(--primary); color: #fff; }

/* ---------- 电脑端 ---------- */
@media (min-width: 640px) {
  .page-bg { height: 360px; }
  .poem-list, .game-grid { grid-template-columns: 1fr 1fr; }
  .pair-grid.many { grid-template-columns: repeat(4, 1fr); }
  .rank-mascot { right: 8px; }
  .shell { padding-left: 24px; padding-right: 24px; }
  .welcome-hero { margin: 0 -24px 8px; padding: 0 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
