/* 小六呈分試特訓營 — 機密檔案風 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { touch-action: manipulation; }

:root {
  --bg: #FFF6E9;
  --dot: rgba(140,100,40,.05);
  --card: #FFFFFF;
  --ink: #33291C;
  --muted: #8A7E6C;
  --line: #EADFC8;
  --math: #2E7DD1;
  --chi: #D8442E;
  --gold: #E8A020;
  --good: #2F9E5F;
  --bad: #D8442E;
  --seal: #C9302B;
  --shadow: 0 2px 10px rgba(120,90,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171E; --dot: rgba(255,240,200,.045); --card: #1E212B; --ink: #EFE8D8;
    --muted: #9A937F; --line: #2C303C; --math: #5B9FE8; --chi: #E86A57;
    --gold: #F0B24A; --good: #4CC07A; --bad: #E86A57; --seal: #E05550;
    --shadow: 0 2px 10px rgba(0,0,0,.3);
  }
}

body {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, "PingFang TC", "Hiragino Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  background-image: radial-gradient(var(--dot) 1.1px, transparent 1.3px);
  background-size: 22px 22px;
  color: var(--ink);
  min-height: 100vh;
  font-size: 17px;
  line-height: 1.55;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
b { font-weight: 900; }

#app { max-width: 700px; margin: 0 auto; padding: 18px 16px 30px; }

/* ---------- 通用元件 ---------- */
.card {
  background: var(--card); border: 2.5px solid var(--line); border-radius: 20px;
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.btn {
  display: block; width: 100%; min-height: 58px; border: none; cursor: pointer;
  border-radius: 18px; font: inherit; font-size: 19px; font-weight: 900; color: #fff;
  background: var(--gold); box-shadow: 0 5px 0 rgba(0,0,0,.16);
  transition: transform .09s, box-shadow .09s; padding: 14px 18px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.16); }
.btn.math { background: var(--math); } .btn.chi { background: var(--chi); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2.5px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.good { background: var(--good); }
.btn + .btn { margin-top: 10px; }
.tag {
  display: inline-block; font-size: 12.5px; font-weight: 900; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 999px; color: #fff; vertical-align: middle;
}
.tag.math { background: var(--math); } .tag.chi { background: var(--chi); } .tag.gold { background: var(--gold); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: 15px;
  background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px;
}

/* ---------- 頂欄 ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.topbar h1 { font-size: 21px; font-weight: 900; letter-spacing: .5px; flex: 1; }
.topbar .pills { display: flex; gap: 6px; }

/* ---------- 等級 ---------- */
.level-card { display: flex; align-items: center; gap: 14px; }
.level-emoji {
  font-size: 34px; width: 62px; height: 62px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  border: 2.5px dashed var(--gold); border-radius: 50%;
}
.level-name { font-size: 18px; font-weight: 900; }
.level-sub { font-size: 13px; color: var(--muted); font-weight: 700; }
.bar { height: 12px; background: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar.math > i { background: var(--math); } .bar.chi > i { background: var(--chi); }

/* ---------- 今日任務 CTA ---------- */
.cta {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 3px solid var(--gold); border-radius: 22px;
  padding: 20px 16px; margin-bottom: 14px; cursor: pointer; font: inherit; color: inherit;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--gold) 45%, transparent);
  transition: transform .09s, box-shadow .09s;
}
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--gold) 45%, transparent); }
.cta .e { font-size: 38px; width: 64px; height: 64px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--gold) 13%, transparent); border: 2.5px dashed var(--gold); border-radius: 50%; }
.cta .k { font-size: 12px; font-weight: 900; letter-spacing: 2px; color: var(--gold); }
.cta .t { font-size: 21px; font-weight: 900; line-height: 1.3; }
.cta .d { font-size: 13.5px; color: var(--muted); font-weight: 700; }
.cta .go { margin-left: auto; font-size: 26px; font-weight: 900; color: var(--gold); }
.corner {
  position: absolute; top: -12px; right: 14px; font-size: 11.5px; font-weight: 900; letter-spacing: 2px;
  background: var(--seal); color: #fff; padding: 3px 10px; border-radius: 8px; transform: rotate(3deg);
}

/* ---------- 任務地圖 ---------- */
.week-folder { margin-bottom: 18px; }
.week-head {
  display: flex; align-items: baseline; gap: 8px; padding: 0 6px 8px;
}
.week-head .wk { font-size: 13px; font-weight: 900; letter-spacing: 2px; color: var(--gold); }
.week-head .nm { font-size: 16px; font-weight: 900; }
.node {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 16px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer; position: relative;
  box-shadow: var(--shadow);
}
.node:disabled { opacity: .55; cursor: default; }
.node .ne { font-size: 24px; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.node.math .ne { background: color-mix(in srgb, var(--math) 12%, transparent); }
.node.chi .ne { background: color-mix(in srgb, var(--chi) 12%, transparent); }
.node.quiz .ne { background: color-mix(in srgb, var(--gold) 15%, transparent); }
.node .nt { font-weight: 900; font-size: 16.5px; }
.node .ns { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.node .nr { margin-left: auto; font-weight: 900; font-size: 14px; white-space: nowrap; }
.node.current { border-color: var(--gold); border-width: 3px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
.node.done { border-style: solid; }
.node .stamp-mini {
  position: absolute; right: 10px; top: -8px; transform: rotate(8deg);
  font-size: 10.5px; font-weight: 900; color: var(--seal); border: 2px solid var(--seal);
  border-radius: 6px; padding: 1px 6px; background: color-mix(in srgb, var(--seal) 6%, var(--card));
}

/* ---------- 會話（每日流程）---------- */
.sess-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sess-x { font-size: 22px; font-weight: 900; color: var(--muted); background: none; border: none; cursor: pointer; padding: 6px 10px; }
.dots { display: flex; gap: 5px; flex: 1; flex-wrap: wrap; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: color-mix(in srgb, var(--line) 70%, transparent); border: 1.5px solid var(--line); }
.dots i.on { background: var(--gold); border-color: var(--gold); }
.dots i.now { border-color: var(--gold); background: var(--card); transform: scale(1.2); }
.sess-star { font-weight: 900; font-size: 16px; white-space: nowrap; }

.phase-card { text-align: center; padding: 34px 20px; }
.phase-card .pe { font-size: 54px; display: block; margin-bottom: 8px; }
.phase-card h2 { font-size: 25px; font-weight: 900; margin-bottom: 4px; }
.phase-card .ps { color: var(--muted); font-weight: 700; margin-bottom: 20px; }
.phase-card.boss { background: color-mix(in srgb, var(--seal) 7%, var(--card)); border-color: var(--seal); }
.phase-card.boss h2 { color: var(--seal); }

/* 秘笈 */
.learn-card .lh { font-size: 20px; font-weight: 900; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.learn-card .lh::before { content: "📖"; }
.learn-card ul { list-style: none; }
.learn-card ul li { padding: 7px 0 7px 30px; position: relative; font-size: 17.5px; font-weight: 600; }
.learn-card ul li::before { content: "▸"; position: absolute; left: 8px; color: var(--gold); font-weight: 900; }
.formula {
  margin: 14px 0; padding: 14px 16px; text-align: center; font-size: 19px; font-weight: 900;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  border: 2.5px dashed var(--gold); border-radius: 14px;
}
.formula::before { content: "🗝️ 口訣 · "; font-size: 13px; letter-spacing: 2px; color: var(--gold); }
table.ltab { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 16px; }
table.ltab th { font-size: 13px; letter-spacing: 1px; color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--line); }
table.ltab td { padding: 8px; border-bottom: 1.5px dashed var(--line); font-weight: 700; }
table.ltab tr:last-child td { border-bottom: none; }
.ex { margin: 8px 0; padding: 12px 14px; background: color-mix(in srgb, var(--line) 30%, transparent); border-radius: 12px; }
.ex .xt { font-weight: 900; font-size: 17px; }
.ex .xs { color: var(--muted); font-weight: 700; font-size: 15.5px; margin-top: 2px; }
.trap { margin-top: 12px; border: 2.5px solid var(--seal); border-radius: 14px; overflow: hidden; }
.trap .th { background: var(--seal); color: #fff; font-weight: 900; font-size: 14px; padding: 6px 12px; letter-spacing: 1px; }
.trap .tb { padding: 10px 14px; font-size: 16px; font-weight: 700; }
.trap .no { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 2.5px; }
.trap .yes { color: var(--good); }
.trap .tw { font-size: 14px; color: var(--muted); font-weight: 700; padding: 0 14px 10px; }

/* 題目 */
.q-sec { font-size: 12.5px; font-weight: 900; letter-spacing: 2px; margin-bottom: 8px; }
.q-sec.warm { color: var(--gold); } .q-sec.prac { color: var(--math); } .q-sec.boss { color: var(--seal); }
.q-passage { padding: 12px 14px; background: color-mix(in srgb, var(--line) 30%, transparent); border-radius: 12px; font-size: 16.5px; margin-bottom: 12px; }
.q-text { font-size: 23px; font-weight: 900; line-height: 1.5; margin-bottom: 18px; }
.opt {
  display: block; width: 100%; min-height: 58px; text-align: left; font: inherit; font-size: 20px; font-weight: 800;
  color: var(--ink); background: var(--card); border: 2.5px solid var(--line); border-radius: 16px;
  padding: 13px 16px 13px 52px; margin-bottom: 10px; cursor: pointer; position: relative;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt::before {
  content: attr(data-k); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; font-weight: 900;
  background: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 50%;
}
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--card)); box-shadow: 0 4px 0 color-mix(in srgb, var(--good) 45%, transparent); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--card)); animation: shake .35s; }
.opt:disabled { cursor: default; opacity: .92; }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

/* 填空（揀字粒） */
.blank-line { font-size: 24px; font-weight: 900; line-height: 2; margin-bottom: 14px; }
.slot {
  display: inline-grid; place-items: center; min-width: 44px; height: 44px; margin: 0 3px; padding: 0 4px;
  border: 2.5px dashed var(--chi); border-radius: 10px; vertical-align: middle; cursor: pointer;
  background: color-mix(in srgb, var(--chi) 6%, transparent); font-size: 22px;
}
.slot.filled { border-style: solid; background: var(--card); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 6px 0 4px; }
.chip {
  font: inherit; font-size: 24px; font-weight: 900; width: 56px; height: 56px; cursor: pointer;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s;
}
.chip:nth-child(odd) { transform: rotate(-2deg); } .chip:nth-child(even) { transform: rotate(2deg); }
.chip:active { transform: translateY(3px); }
.chip.used { opacity: .25; pointer-events: none; }

/* 數字鍵盤 */
.numshow {
  min-height: 60px; display: grid; place-items: center; font-size: 30px; font-weight: 900;
  border: 2.5px dashed var(--math); border-radius: 14px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--math) 5%, transparent); letter-spacing: 2px;
}
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; max-width: 340px; margin: 0 auto; }
.numpad button {
  font: inherit; font-size: 24px; font-weight: 900; min-height: 58px; cursor: pointer;
  background: var(--card); color: var(--ink); border: 2.5px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s;
}
.numpad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

/* 反饋 */
.fb { margin-top: 14px; border-radius: 16px; padding: 14px 16px; animation: rise .25s; }
.fb.ok { background: color-mix(in srgb, var(--good) 10%, var(--card)); border: 2.5px solid var(--good); }
.fb.ko { background: color-mix(in srgb, var(--bad) 8%, var(--card)); border: 2.5px solid var(--bad); }
.fb .fh { font-size: 19px; font-weight: 900; margin-bottom: 3px; }
.fb.ok .fh { color: var(--good); } .fb.ko .fh { color: var(--bad); }
.fb .fw { font-weight: 700; font-size: 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* 完成 & 印章 */
.done-wrap { text-align: center; padding: 26px 18px; }
.done-wrap h2 { font-size: 26px; font-weight: 900; margin: 6px 0 2px; }
.done-sub { color: var(--muted); font-weight: 700; margin-bottom: 16px; }
.seal {
  width: 148px; height: 148px; margin: 14px auto; display: grid; place-items: center; text-align: center;
  border: 5px solid var(--seal); border-radius: 50%; color: var(--seal);
  font-weight: 900; transform: rotate(-8deg); position: relative;
  animation: slam .5s cubic-bezier(.2,2.4,.4,1) both .25s;
}
.seal .s1 { font-size: 15px; letter-spacing: 3px; }
.seal .s2 { font-size: 30px; letter-spacing: 2px; }
.seal .s3 { font-size: 12.5px; letter-spacing: 1px; }
.seal::after { content: ""; position: absolute; inset: 6px; border: 2px solid var(--seal); border-radius: 50%; opacity: .6; }
@keyframes slam { 0% { transform: rotate(-8deg) scale(2.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-8deg) scale(1); opacity: 1; } }
.stat-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 18px; }
.stat { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 16px; font-weight: 900; font-size: 17px; }
.stat i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }
.tmr-card { border: 2.5px dashed var(--line); border-radius: 16px; padding: 12px; margin-bottom: 16px; font-weight: 700; color: var(--muted); font-size: 15px; }

/* 打卡日曆 / 進度 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.cal .ch { font-size: 11.5px; font-weight: 900; color: var(--muted); text-align: center; letter-spacing: 1px; }
.cal .cd {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; font-weight: 800; font-size: 14px;
  border: 2px solid var(--line); background: var(--card); position: relative;
}
.cal .cd.off { opacity: .35; border-style: dashed; background: transparent; }
.cal .cd.hit { border-color: var(--seal); color: var(--seal); }
.cal .cd.hit::after { content: "✓"; position: absolute; font-size: 22px; font-weight: 900; opacity: .85; transform: rotate(-10deg); }
.cal .cd.hit span { opacity: .25; }
.cal .cd.today { outline: 3px solid var(--gold); outline-offset: 1px; }
.badge-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.bdg { text-align: center; border: 2px solid var(--line); border-radius: 14px; padding: 10px 6px; background: var(--card); }
.bdg .be { font-size: 30px; } .bdg .bn { font-size: 12px; font-weight: 900; margin-top: 3px; }
.bdg .bd { font-size: 10.5px; color: var(--muted); font-weight: 700; }
.bdg.lock { opacity: .38; filter: grayscale(1); border-style: dashed; }
.weak { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1.5px dashed var(--line); }
.weak:last-child { border-bottom: none; }
.weak .wn { font-weight: 900; font-size: 16px; flex: 1; }
.weak .wc { color: var(--muted); font-weight: 700; font-size: 13px; }
.weak button { font: inherit; font-weight: 900; font-size: 14px; color: #fff; background: var(--gold); border: none; border-radius: 10px; padding: 8px 14px; cursor: pointer; }
h3.sec { font-size: 15px; font-weight: 900; letter-spacing: 2px; color: var(--muted); margin: 22px 6px 10px; }

/* 底欄 */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; gap: 6px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 2.5px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
#tabbar a {
  flex: 1; max-width: 180px; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 20px; font-weight: 900; border-radius: 14px; padding: 6px 4px; line-height: 1.15;
}
#tabbar a span { display: block; font-size: 11.5px; letter-spacing: 1px; }
#tabbar a.on { color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
body.in-session #tabbar { display: none; }

/* Toast + 星星飛 + 彩紙 */
#toasts { position: fixed; top: 14px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--bg); font-weight: 900; font-size: 16px;
  border-radius: 999px; padding: 10px 20px; animation: toast 2.2s both; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
@keyframes toast { 0% { opacity: 0; transform: translateY(-16px); } 12%,82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }
.confetti { position: fixed; width: 10px; height: 14px; top: -20px; z-index: 80; pointer-events: none; animation: fall linear both; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

.foot-note { text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 20px; }
.linkrow { display: flex; gap: 10px; }
.linkrow .card { flex: 1; text-align: center; text-decoration: none; color: inherit; font-weight: 900; padding: 13px; margin: 0; font-size: 15px; }

@media (max-width: 420px) {
  .q-text { font-size: 20px; }
  .chip { width: 50px; height: 50px; font-size: 21px; }
}
