:root {
  --bg: #fff8ec; --bg2: #fff1d6; --ink: #4a3b2a; --muted: #9a8a72;
  --primary: #ffb703; --primary-d: #fb8500;
  --green: #43aa8b; --green-l: #cdefe3;
  --red: #ef6f6c; --blue: #4d96ff; --purple: #9b6bd6;
  --card: #ffffff; --line: #e8dbc9;
  --shadow: 0 6px 0 rgba(0,0,0,.08), 0 10px 24px rgba(120,80,0,.12);
  --radius: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Noto Sans SC', system-ui, sans-serif; color: var(--ink);
  background: radial-gradient(circle at 50% -10%, var(--bg2), var(--bg) 60%);
  min-height: 100%; overflow-x: hidden; user-select: none;
}
h2 { font-family: 'ZCOOL KuaiLe', 'Noto Sans SC', sans-serif; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100vh; padding: 16px; max-width: 760px; margin: 0 auto; flex-direction: column; }
.screen.active { display: flex; animation: fade .35s ease; }
@keyframes fade { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ---------- brand / profile ---------- */
.brand { text-align: center; margin: 8vh 0 4vh; }
.logo { font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 56px; color: var(--primary-d);
  text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(251,133,0,.25); letter-spacing: 4px; }
.logo-sub { color: var(--muted); margin-top: 6px; letter-spacing: 1px; }
.profile-prompt { text-align: center; font-size: 18px; color: var(--ink); }
.profile-list { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.profile-btn {
  background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 26px; cursor: pointer; transition: transform .15s; min-width: 140px; position: relative;
}
.profile-btn:active { transform: scale(.95); }
.profile-btn .av { font-size: 64px; }
.profile-btn .nm { margin-top: 8px; font-size: 20px; font-weight: 700; }
.profile-btn .lv { color: var(--muted); font-size: 13px; }
.profile-btn .lock { position: absolute; top: 10px; right: 12px; font-size: 18px; }

/* ---------- PIN screen ---------- */
#screen-pin.active { justify-content: center; align-items: center; }
.pin-wrap { background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 32px 24px; text-align: center; max-width: 360px; width: 100%; }
.pin-avatar { font-size: 80px; animation: bob 2.4s ease-in-out infinite; margin-bottom: 4px; }
.pin-name { font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 26px; color: var(--primary-d); margin-bottom: 4px; }
.pin-hint { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }
.pin-field-wrap { position: relative; margin-bottom: 6px; }
.pin-input {
  width: 100%; padding: 14px 48px 14px 16px; font-size: 20px; letter-spacing: 4px;
  border: 2px solid #e8dbc9; border-radius: 14px; font-family: inherit;
  background: #fffaf3; text-align: center; outline: none; transition: border-color .2s;
}
.pin-input:focus { border-color: var(--primary); }
.pin-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }
.pin-error { color: var(--red); font-size: 14px; margin: 4px 0; }
.pin-submit { width: 100%; margin-top: 10px; padding: 16px; font-size: 18px; }
.pin-back { width: 100%; margin-top: 10px; padding: 12px; font-size: 15px; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.topbar .game-title, .topbar .who { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }
.chip {
  background: var(--card); border: none; border-radius: 999px; box-shadow: var(--shadow);
  padding: 10px 14px; font-size: 15px; cursor: pointer; font-family: inherit; color: var(--ink);
  transition: transform .12s; white-space: nowrap;
}
.chip:active { transform: scale(.92); }
.chip.ghost { box-shadow: none; background: rgba(255,255,255,.6); color: var(--muted); }

/* ---------- XP chip + progress ---------- */
.xp-row { margin: -4px 0 10px; }
.xp-chip {
  display: block; background: linear-gradient(135deg, #fb8500, #ffb703);
  color: #fff; border-radius: 14px; padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(251,133,0,.3);
}
.xp-top { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; flex-wrap: wrap; }
.xp-next { font-size: 13px; opacity: .85; margin-left: auto; }
.xp-bar { height: 7px; background: rgba(255,255,255,.3); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: #fff; border-radius: 99px; transition: width .6s ease; }

/* ---------- mascot ---------- */
.mascot-area { display: flex; align-items: center; gap: 14px; margin: 6px 4px 14px; }
.mascot { font-size: 72px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translateY(0) rotate(-2deg);} 50%{transform:translateY(-8px) rotate(2deg);} }
.bubble { background: var(--card); border-radius: 18px; padding: 12px 16px; box-shadow: var(--shadow);
  position: relative; font-size: 16px; flex: 1; }
.bubble::before { content:''; position:absolute; left:-10px; top:26px; border:8px solid transparent; border-right-color:var(--card); }

/* ---------- daily goal ---------- */
.daily { background: var(--green-l); color: #2c6e5b; border-radius: 16px; padding: 12px 16px;
  margin-bottom: 16px; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.daily .dots { display: flex; gap: 6px; }
.daily .dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #8fd3c0; }
.daily .dot.on { background: var(--green); box-shadow: none; }

/* ---------- sound button (home) ---------- */
.sound-row { text-align: center; margin-top: 12px; }
.sound-btn { background: none; border: none; font-size: 15px; color: var(--muted); cursor: pointer; font-family: inherit; padding: 6px 12px; }

/* ---------- menu tiles ---------- */
.menu { display: grid; gap: 14px; }
.tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  gap: 2px 16px; align-items: center; text-align: left;
  border: none; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; cursor: pointer; font-family: inherit; color: #fff; transition: transform .12s;
}
.tile:active { transform: scale(.97); }
.tile-emoji { grid-row: 1 / span 2; font-size: 44px; }
.tile-title { font-size: 22px; font-weight: 700; }
.tile-desc { font-size: 13px; opacity: .9; }
.tile-pinyin   { background: linear-gradient(135deg, #4d96ff, #6aa9ff); }
.tile-sentence { background: linear-gradient(135deg, #43aa8b, #5cc4a3); }
.tile-memory   { background: linear-gradient(135deg, #9b6bd6, #b48be6); }
.tile-similar  { background: linear-gradient(135deg, #ef6f6c, #f49090); }

.menu-secondary { display: flex; gap: 14px; margin-top: 16px; }
.tile2 { flex: 1; background: var(--card); border: none; border-radius: 16px; box-shadow: var(--shadow);
  padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; color: var(--ink); }
.tile2 span { display: block; font-size: 30px; margin-bottom: 4px; }
.tile2:active { transform: scale(.96); }

/* ---------- settings ---------- */
#screen-settings { overflow-y: auto; }
.settings-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px; margin-bottom: 16px; }
.settings-section-title { font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 20px; color: var(--primary-d); margin-bottom: 8px; }
.settings-hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; line-height: 1.5; }
.settings-label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.settings-input { width: 100%; padding: 12px 14px; border: 2px solid #e8dbc9; border-radius: 12px;
  font-family: inherit; font-size: 16px; background: #fffaf3; outline: none; }
.settings-input:focus { border-color: var(--primary); }
.settings-status { font-size: 13px; margin: 6px 0; min-height: 18px; color: var(--green); }
.settings-status.err { color: var(--red); }

/* avatar picker */
.avatar-current { font-size: 72px; text-align: center; cursor: pointer; transition: transform .2s;
  padding: 8px; border-radius: 16px; display: inline-block; }
.avatar-current.selecting { background: #fff7e0; box-shadow: 0 0 0 3px var(--primary); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin-top: 10px; }
.avatar-opt { font-size: 38px; background: #f8f3ea; border: 3px solid transparent; border-radius: 12px;
  cursor: pointer; padding: 6px; text-align: center; transition: transform .12s, border-color .12s; }
.avatar-opt:active { transform: scale(.9); }
.avatar-opt.chosen { border-color: var(--primary); background: #fff7e0; }
.avatar-opt.avatar-locked { cursor: not-allowed; opacity: .55; position: relative; }
.av-lock-emoji { font-size: 30px; display: block; filter: grayscale(1); }
.av-lock-label { font-size: 9px; color: #9a8a72; margin-top: 2px; line-height: 1.2; }
.avatar-tier-header { grid-column: 1/-1; font-size: 13px; font-weight: 700; color: var(--primary-d);
  padding: 8px 2px 2px; letter-spacing: .3px; }

/* danger button */
.btn-danger { background: #fff0ee; color: var(--red); border: 2px solid var(--red); border-radius: 14px;
  padding: 12px 24px; font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn-danger:active { background: var(--red); color: #fff; }

/* ---------- game board ---------- */
.game-board { flex: 1; }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-card {
  background: var(--card); border: 3px solid transparent; border-radius: 16px; box-shadow: var(--shadow);
  padding: 16px 12px; min-height: 64px; display: flex; align-items: center; justify-content: center;
  text-align: center; cursor: pointer; font-size: 22px; transition: transform .12s, border-color .15s, background .15s;
}
.match-card.small { font-size: 16px; line-height: 1.5; }
.match-card:active { transform: scale(.97); }
.match-card.selected { border-color: var(--primary); background: #fff7e0; }
.match-card.correct { border-color: var(--green); background: var(--green-l); color: #2c6e5b; cursor: default; pointer-events: none; }
.match-card.gone { opacity: 0; transform: scale(.6); pointer-events: none; transition: all .4s; }
.match-card.wrong { animation: shake .4s; border-color: var(--red); }
.match-card.hz, .flip-front.hz { font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; }
@keyframes shake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-7px);} 40%{transform:translateX(7px);} 60%{transform:translateX(-5px);} 80%{transform:translateX(5px);} }

/* ---------- memory grid ---------- */
.memory-grid { display: grid; gap: 10px; }
.flip { aspect-ratio: 3/4; perspective: 700px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.flip.up .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); padding: 6px; text-align: center; }
.flip-back { background: linear-gradient(135deg, var(--primary), var(--primary-d)); color: #fff; font-size: 30px; }
.flip-front { background: var(--card); transform: rotateY(180deg); font-size: 20px; color: var(--ink); }
.flip.matched .flip-inner { animation: pop .4s; }
.flip.matched .flip-front { background: var(--green-l); border: 3px solid var(--green); }
@keyframes pop { 0%{transform:rotateY(180deg) scale(1);} 50%{transform:rotateY(180deg) scale(1.12);} 100%{transform:rotateY(180deg) scale(1);} }

/* ---------- result ---------- */
#screen-result.active { justify-content: center; align-items: center; }
.result-card { background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 28px 22px;
  text-align: center; max-width: 460px; width: 100%; }
.result-emoji { font-size: 64px; animation: bob 2s ease-in-out infinite; }
.result-card h2 { margin: 6px 0; font-size: 30px; color: var(--primary-d); }
#result-sub { color: var(--muted); margin: 0 0 8px; }
.gotcha { margin: 16px 0; }
.gotcha.hidden { display: none; }
.gotcha-label { color: var(--purple); font-weight: 700; margin-bottom: 8px; }
.scroll { background: linear-gradient(#fffaf0, #fff3d6); border: 2px dashed var(--primary);
  border-radius: 16px; padding: 18px; animation: unfurl .6s ease; transform-origin: top; }
@keyframes unfurl { from{transform:scaleY(0);opacity:0;} to{transform:scaleY(1);opacity:1;} }
.scroll-text { font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; font-size: 24px; color: var(--ink); line-height: 1.6; }
.scroll-pinyin { color: var(--primary-d); margin: 6px 0; font-size: 14px; letter-spacing: .5px; }
.scroll-meaning { color: var(--muted); font-size: 14px; line-height: 1.6; }
.speak-btn, .gotcha-section { margin-top: 10px; }
.speak-btn { background: var(--purple); color: #fff; border: none; border-radius: 999px; padding: 8px 16px;
  font-family: inherit; font-size: 14px; cursor: pointer; }
.gotcha-section { color: var(--muted); font-size: 13px; }
.result-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.badge-pop { background: #fff7e0; border: 2px solid var(--primary); border-radius: 14px; padding: 8px 12px;
  animation: pop2 .5s ease; }
@keyframes pop2 { 0%{transform:scale(0) rotate(-20deg);} 70%{transform:scale(1.15);} 100%{transform:scale(1);} }
.badge-pop .bi { font-size: 30px; } .badge-pop .bn { font-size: 13px; font-weight: 700; }
.result-actions { display: flex; gap: 12px; margin-top: 16px; }
.btn-primary, .btn-ghost { flex: 1; border: none; border-radius: 16px; padding: 14px; font-size: 17px;
  font-family: inherit; font-weight: 700; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-d); }
.btn-primary:active { transform: translateY(3px); box-shadow: none; }
.btn-ghost { background: #f0e7d6; color: var(--ink); }

/* ---------- collection tabs ---------- */
.coll-tabs { display: flex; gap: 8px; padding: 10px 16px 0; }
.coll-tab { flex: 1; padding: 10px 8px; border: 2px solid var(--primary); border-radius: 12px;
  background: transparent; color: var(--primary-d); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background .2s, color .2s; font-family: inherit; }
.coll-tab.active { background: var(--primary); color: #fff; }
.coll-tab:disabled { border-color: #ccc; color: #bbb; cursor: not-allowed; }

/* ---------- TSG lock hint ---------- */
.tsg-lock-hint { text-align: center; margin: 32px 16px; padding: 28px 20px;
  background: linear-gradient(135deg, #f9f3ea, #f0e8d8); border-radius: 20px;
  border: 2px dashed var(--primary); }
.tsg-lock-icon { font-size: 48px; margin-bottom: 10px; }
.tsg-lock-title { font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 20px; color: var(--primary-d); font-weight: 700; }
.tsg-lock-desc { color: var(--muted); font-size: 14px; margin-top: 6px; }
.tsg-lock-prog { margin-top: 10px; font-size: 13px; color: var(--primary-d); font-weight: 700; }

/* ---------- collection ---------- */
.collection-body, .badges-body { flex: 1; overflow-y: auto; padding-bottom: 30px; }
.coll-section { margin-bottom: 18px; }
.coll-section h3 { font-family: 'ZCOOL KuaiLe', sans-serif; color: var(--primary-d); margin: 8px 4px; }
.coll-grid { display: grid; gap: 10px; }
.verse-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; }
.verse-card.locked { background: repeating-linear-gradient(45deg,#f3ece0,#f3ece0 8px,#efe6d6 8px,#efe6d6 16px);
  color: #b9ab94; cursor: default; }
.verse-card .vt { font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; font-size: 20px; }
.verse-stars { font-size: 13px; margin: 2px 0 3px; letter-spacing: 2px; }
.verse-card .vp { color: var(--primary-d); font-size: 13px; margin-top: 4px; }
.verse-card .vm { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.6; display: none; }
.verse-card.open .vm { display: block; }

/* ---------- badges ---------- */
.badge-section { margin-bottom: 20px; }
.badge-section-title { font-size: 14px; font-weight: 700; padding: 6px 4px 8px;
  letter-spacing: .5px; color: var(--muted); }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); gap: 12px; }
.badge-cell { border-radius: 16px; box-shadow: var(--shadow); padding: 14px 10px; text-align: center; }
.badge-cell.diff-easy   { background: linear-gradient(135deg,#f0fdf4,#dcfce7); border: 1.5px solid #86efac; }
.badge-cell.diff-medium { background: linear-gradient(135deg,#eff6ff,#dbeafe); border: 1.5px solid #93c5fd; }
.badge-cell.diff-hard   { background: linear-gradient(135deg,#fff1f2,#ffe4e6); border: 1.5px solid #fca5a5; }
.badge-cell.locked { filter: grayscale(1); opacity: .45; }
.badge-cell .bi { font-size: 40px; }
.badge-cell .bn { font-weight: 700; margin-top: 4px; font-size: 13px; }
.badge-cell .bd { color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.4; }

/* ---------- level picker ---------- */
.level-picker-overlay { position:fixed; inset:0; z-index:8000; background:rgba(20,10,0,.55);
  display:flex; align-items:flex-end; justify-content:center; padding:0 0 env(safe-area-inset-bottom,0); }
.level-picker-overlay.hidden { display:none; }
.level-picker-sheet { background:#fffbf2; border-radius:24px 24px 0 0; padding:24px 20px 28px;
  width:100%; max-width:480px; animation:slideUp .25s ease; }
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.level-picker-title { font-family:'ZCOOL KuaiLe',sans-serif; font-size:20px; color:var(--primary-d);
  margin-bottom:16px; text-align:center; }
.level-picker-btns { display:grid; gap:10px; margin-bottom:14px; }
.level-pick-btn { display:grid; grid-template-columns:1fr; text-align:left; padding:14px 18px;
  border:2px solid #e8dbc9; border-radius:14px; background:#fff; font-family:inherit;
  cursor:pointer; transition:background .15s,border-color .15s; }
.level-pick-btn.current { border-color:var(--primary); background:#fff8ec; }
.level-pick-btn:active { background:#fdefd4; }
.lpb-label { font-size:17px; font-weight:700; color:var(--ink); }
.lpb-sub { font-size:12px; color:var(--muted); margin-top:2px; }
.level-picker-cancel { width:100%; padding:14px; border-radius:14px; font-size:16px; }

/* ---------- 相似字 game ---------- */
.sim-prog-bar { height:6px; background:#e8dbc9; border-radius:99px; margin:0 0 20px;
  overflow:hidden; }
.sim-prog-fill { height:100%; background:var(--primary); border-radius:99px; transition:width .3s; }
.sim-target { text-align:center; padding:18px 10px 14px; }
.sim-question { font-size:14px; color:var(--muted); margin-bottom:8px; }
.sim-char { font-family:'Ma Shan Zheng','ZCOOL KuaiLe',sans-serif; font-size:96px; line-height:1;
  color:var(--ink); }
.sim-label { font-size:14px; color:var(--primary-d); margin-top:6px; font-weight:600; }
.sim-choices { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin:4px 0; }
.sim-choice { font-family:'Ma Shan Zheng','ZCOOL KuaiLe',sans-serif; font-size:52px;
  background:var(--card); border:3px solid #e8dbc9; border-radius:18px; cursor:pointer;
  padding:16px 10px; text-align:center; transition:transform .1s,border-color .15s; line-height:1; }
.sim-choice:active { transform:scale(.93); }
.sim-choice.correct { border-color:#43aa8b; background:#edfaf5; }
.sim-choice.wrong { border-color:#ef6f6c; background:#fff0ee; animation:shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.sim-counter { text-align:center; font-size:13px; color:var(--muted); margin-top:12px; }

/* ---------- 太上感应篇 unlock overlay ---------- */
.tsg-unlock-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(20,10,0,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.tsg-unlock-overlay.hidden { display: none; }
.tsg-unlock-card {
  background: linear-gradient(160deg, #fffbf0 0%, #fff3d0 60%, #ffe8a0 100%);
  border-radius: 28px; box-shadow: 0 24px 60px rgba(120,70,0,.35);
  padding: 36px 28px 32px; max-width: 360px; width: 100%;
  text-align: center; animation: tsgPop .5s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes tsgPop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.tsg-unlock-fireworks { font-size: 36px; letter-spacing: 6px; margin-bottom: 8px; }
.tsg-unlock-title {
  font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 38px;
  color: #c05e00; margin: 0 0 10px; line-height: 1.1;
}
.tsg-unlock-verse {
  font-family: 'Ma Shan Zheng', sans-serif; font-size: 20px;
  color: #3a2a10; line-height: 1.7; margin-bottom: 12px;
}
.tsg-unlock-praise {
  font-size: 15px; color: #7a5a2a; line-height: 1.8;
  margin-bottom: 20px; font-style: italic;
}
.tsg-unlock-reveal {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(135deg, #fff8e0, #fdecc0);
  border: 2px solid #f0c060; border-radius: 18px;
  padding: 16px 20px; margin-bottom: 18px;
}
.tsg-unlock-icon-big { font-size: 44px; flex-shrink: 0; }
.tsg-unlock-reveal-text { text-align: left; font-size: 17px; line-height: 1.6; color: #3a2a10; }
.tsg-unlock-reveal-text strong { font-family: 'ZCOOL KuaiLe', sans-serif; font-size: 20px; color: #c05e00; }
.tsg-unlock-hint { font-size: 14px; color: #9a7a40; line-height: 1.8; margin: 0 0 22px; }
.tsg-unlock-btn { width: 100%; padding: 16px; font-size: 18px; border-radius: 16px;
  background: linear-gradient(135deg, #fb8500, #ffb703); color: #fff;
  font-weight: 700; font-family: inherit; border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(251,133,0,.4); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(40px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; opacity: 0;
  transition: all .3s; z-index: 1000; font-size: 15px; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }
@media (min-width: 560px) { .memory-grid { max-width: 520px; margin: 0 auto; } }

/* ================================================================
   DICTATION — 听写 / 默写
   ================================================================ */

/* home tile */
.tile-dictation {
  background: linear-gradient(135deg, #e76f51, #f4a261);
  margin-top: 14px;
  width: 100%;
}

/* ---------- list screen ---------- */
.dict-list-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.dict-section-title {
  font-family: 'ZCOOL KuaiLe', sans-serif; color: var(--primary-d);
  margin: 16px 4px 8px; font-size: 20px;
}
.dict-card {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 12px;
}
.dict-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.dict-card-title { font-size: 18px; font-weight: 700; flex: 1; }
.dict-type-badge {
  color: #fff; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.dict-card-meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.dict-card-meta .best-score { color: var(--green); font-weight: 700; }
.dict-card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dict-card-btn {
  flex: 1; min-width: 80px; border: none; border-radius: 12px; padding: 10px 8px;
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .12s;
}
.dict-card-btn:active { transform: scale(.95); }
.dict-btn-prac  { background: var(--green-l); color: #2c6e5b; }
.dict-btn-ting  { background: #dbeafe; color: #1e40af; }
.dict-btn-mo    { background: #ede9fe; color: #5b21b6; }

/* ---------- practice screen ---------- */
.dict-prac-progress-bar, .dict-test-progress-bar {
  height: 6px; background: #e8dbc9; border-radius: 99px;
  margin: 0 0 18px; overflow: hidden;
}
.dict-prac-progress-bar div, .dict-test-progress-bar div {
  height: 100%; background: var(--primary); border-radius: 99px;
  transition: width .4s ease;
}
.dict-practice-body { flex: 1; display: flex; flex-direction: column; align-items: center; }
.prac-card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 28px 24px; width: 100%; max-width: 480px;
  text-align: center; animation: fade .3s ease;
}
.prac-hanzi {
  font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; font-size: 64px;
  color: var(--ink); line-height: 1.1; margin-bottom: 6px;
}
.prac-pinyin { color: var(--primary-d); font-size: 20px; margin-bottom: 8px; letter-spacing: 1px; }
.prac-meaning { color: var(--muted); font-size: 15px; line-height: 1.6; min-height: 24px; }
.dict-big-audio {
  margin-top: 24px; width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border: none; font-size: 38px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s; animation: bob 2.4s ease-in-out infinite;
}
.dict-big-audio:active { transform: scale(.9) !important; animation: none; }
.dict-prac-nav {
  display: flex; gap: 12px; margin-top: 18px; padding-bottom: 8px;
}
.dict-prac-nav .chip { flex: 1; text-align: center; }
.prac-next-btn { flex: 2; }

/* ---------- test screen ---------- */
.dict-test-body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.test-instruction { color: var(--muted); font-size: 14px; text-align: center; }
.test-audio-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.test-read-status { font-size: 13px; color: var(--muted); min-height: 18px; }
.test-read-status.done { color: var(--green); font-weight: 700; }
.test-skip-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 12px; font-family: inherit; font-size: 13px; color: var(--muted);
  cursor: pointer; margin-top: 4px; transition: border-color .15s;
}
.test-skip-btn:hover { border-color: var(--primary); color: var(--primary-d); }

/* 默写 meaning box */
.test-moxa-box {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 20px 22px; width: 100%; max-width: 480px; text-align: center;
}
.test-moxa-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.test-moxa-meaning { font-size: 20px; color: var(--ink); line-height: 1.6; }

/* 默写 flash card (look-cover-write-check) */
.mo-flash-box {
  background: linear-gradient(135deg, #9b6bd6, #b48be6); color: #fff;
  border-radius: 22px; box-shadow: var(--shadow);
  padding: 24px 28px; width: 100%; max-width: 480px; text-align: center;
  animation: fade .3s ease;
}
.mo-flash-label { font-size: 13px; opacity: .85; margin-bottom: 6px; letter-spacing: 1px; }
.mo-flash-hanzi {
  font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif;
  font-size: 64px; line-height: 1.1; margin-bottom: 4px;
}
.mo-flash-pinyin { font-size: 18px; opacity: .9; letter-spacing: 1px; margin-bottom: 10px; }
.mo-flash-countdown {
  display: inline-block; width: 36px; height: 36px; line-height: 36px;
  background: rgba(255,255,255,.25); border-radius: 50%;
  font-size: 18px; font-weight: 700;
}

/* bell button for 默写 */
.dict-bell-btn {
  background: linear-gradient(135deg, var(--purple), #b48be6);
  color: #fff; border: none; border-radius: 999px;
  padding: 14px 28px; font-family: inherit; font-size: 18px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s;
}
.dict-bell-btn:active { transform: scale(.93); }

/* reveal area */
.test-reveal-area {
  width: 100%; max-width: 480px; text-align: center;
  min-height: 80px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.reveal-btn {
  background: #fff3d6; border: 2px dashed var(--primary); border-radius: 14px;
  padding: 14px 28px; font-family: inherit; font-size: 17px; font-weight: 700;
  cursor: pointer; color: var(--primary-d); transition: transform .12s;
}
.reveal-btn:active { transform: scale(.96); }
.reveal-hint-box {
  background: #fff8ec; border-radius: 14px; padding: 14px 20px; text-align: center;
  animation: fade .25s ease;
}
.reveal-hint-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.reveal-hint-char { font-size: 52px; font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; color: var(--ink); }
.reveal-full-box {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 18px 24px; text-align: center; animation: unfurl .4s ease;
}
.reveal-full-hanzi { font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; font-size: 48px; color: var(--ink); }
.reveal-full-pinyin { color: var(--primary-d); font-size: 18px; margin-top: 4px; }

/* mark buttons */
.test-mark-btns { display: flex; gap: 16px; width: 100%; max-width: 480px; }
.mark-correct, .mark-wrong {
  flex: 1; border: none; border-radius: 16px; padding: 16px;
  font-family: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform .12s;
}
.mark-correct:active, .mark-wrong:active { transform: scale(.95); }
.mark-correct { background: var(--green-l); color: #2c6e5b; }
.mark-wrong   { background: #fde8e8; color: #c0392b; }

/* writing canvas (田字格) */
.write-canvas-wrap {
  width: 100%; max-width: 480px; align-self: stretch;
  display: flex; flex-direction: column; gap: 8px;
}
.write-canvas {
  width: 100%; min-height: 80px;
  border-radius: 14px; border: 2px solid var(--line);
  background: #fffcf4; touch-action: none; cursor: crosshair;
  display: block;
}
.write-btns { display: flex; gap: 8px; justify-content: flex-end; }
.write-clear-btn {
  background: #f0e7d6; border: none; border-radius: 10px;
  padding: 7px 14px; font-family: inherit; font-size: 14px;
  color: var(--ink); cursor: pointer; transition: transform .1s;
}
.write-clear-btn:active { transform: scale(.95); }
.write-eraser-btn {
  background: #f0e7d6; border: none; border-radius: 10px;
  padding: 7px 14px; font-family: inherit; font-size: 14px;
  color: var(--ink); cursor: pointer; transition: transform .1s, background .15s, color .15s;
  margin-right: auto;
}
.write-eraser-btn:active { transform: scale(.95); }
.write-eraser-btn.active {
  background: linear-gradient(135deg, #ffb703, #fb8500); color: #fff; font-weight: 700;
}
.write-canvas.erasing { cursor: cell; }
.write-ocr-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  border: none; border-radius: 10px; padding: 7px 14px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: transform .1s, opacity .15s;
}
.write-ocr-btn:active  { transform: scale(.95); }
.write-ocr-btn:disabled { opacity: .6; cursor: default; }
.ocr-result { min-height: 24px; text-align: center; }
.ocr-ok {
  display: block; background: var(--green-l); color: #1d6e55;
  border: 2px solid var(--green); border-radius: 14px;
  padding: 12px 16px; font-size: 20px; font-weight: 700;
  animation: pop2 .4s ease;
}
.ocr-diff {
  display: block; background: #fff7e0; color: var(--primary-d);
  border: 2px solid var(--primary); border-radius: 14px;
  padding: 12px 16px; font-size: 18px; font-weight: 700;
  animation: pop2 .4s ease;
}
.ocr-err {
  display: block; background: #fde8e8; color: #c0392b;
  border: 2px solid var(--red); border-radius: 14px;
  padding: 10px 14px; font-size: 16px; font-weight: 700;
}
.ocr-text { display: block; color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ---------- result screen ---------- */
#screen-dict-result.active { justify-content: center; align-items: center; }
.dict-result-wrap { width: 100%; display: flex; justify-content: center; }
.dict-result-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 28px 22px; text-align: center; max-width: 460px; width: 100%;
}
.dict-result-emoji { font-size: 72px; animation: bob 2s ease-in-out infinite; }
.dict-result-card h2 { color: var(--primary-d); margin: 8px 0 4px; font-size: 26px; }
.dict-result-score { font-size: 42px; font-weight: 700; color: var(--ink); margin: 4px 0 16px; }
.dict-wrong-list { text-align: left; margin: 12px 0; }
.wrong-section-title { color: var(--muted); font-size: 13px; margin-bottom: 8px; font-weight: 700; }
.wrong-word {
  display: flex; align-items: baseline; gap: 10px;
  background: #fde8e8; border-radius: 10px; padding: 8px 12px; margin-bottom: 6px;
}
.wrong-hanzi { font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', sans-serif; font-size: 22px; color: var(--ink); }
.wrong-pinyin { color: var(--muted); font-size: 14px; }
.all-correct-msg { color: var(--green); font-size: 17px; font-weight: 700; text-align: center; padding: 8px 0; }
.dict-xp-gained {
  color: var(--primary-d); font-size: 22px; font-weight: 700;
  animation: pop2 .5s ease; margin: -8px 0 8px;
}
.dict-result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.dict-result-actions .btn-primary,
.dict-result-actions .btn-ghost { flex: none; width: 100%; }

/* ---------- admin dictation tab ---------- */
.dict-admin-create {
  background: #f8f3ea; border-radius: 14px; padding: 16px; margin-bottom: 18px;
}
.dict-admin-create h3 { margin: 0 0 12px; color: var(--primary); font-size: 17px; }
.dict-admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dict-admin-form.wide { grid-template-columns: 1fr; }
.dict-admin-form label { font-size: 12px; color: #9a8a72; display: block; margin-bottom: 2px; }
.dict-admin-form input,
.dict-admin-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; }
.dict-list-item {
  border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden;
}
.dict-list-item.inactive { opacity: .55; }
.dict-list-header {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  background: #fdf6ec; cursor: pointer;
}
.dict-list-header:hover { background: #fdefd4; }
.dict-list-hbadge {
  font-size: 12px; border-radius: 999px; padding: 2px 8px; color: #fff; font-weight: 700;
}
.dict-list-htitle { flex: 1; font-weight: 700; font-size: 15px; }
.dict-list-hmeta { font-size: 12px; color: var(--muted); }
.dict-list-toggles { display: flex; gap: 6px; }
.dict-list-toggles button {
  font-size: 13px; border: none; border-radius: 8px; padding: 4px 8px;
  cursor: pointer; background: #e8dbc9; color: var(--ink);
}
.dict-list-toggles button.on { background: var(--primary); color: #fff; }
.dict-list-body-inner { padding: 12px 14px; border-top: 1px dashed var(--line); display: none; }
.dict-list-item.open .dict-list-body-inner { display: block; }
.dict-word-row { display: grid; grid-template-columns: 1.2fr 1.5fr 0.8fr 2fr auto; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px dashed #f0e4cc; }
.dict-word-row input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; width: 100%; }
.dict-word-row-head { font-size: 11px; color: var(--muted); font-weight: 700; }
.dict-assign-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.dict-assign-row label { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.dict-assign-row input { width: auto; }

@media (max-width: 600px) {
  .dict-word-row { grid-template-columns: 1fr 1fr auto; }
  .dict-word-row .hint-col, .dict-word-row .meaning-col { grid-column: 1 / -2; }
}
