/* 秒懂麻將：跟 lazymakers.com 同一家（色票、手寫標題、白紙硬影子、黃色按鈕）。
   手機優先：先把 390 寬做好，900 以上才改電腦版排法。
   整站文字不能反白（使用者要求）；輸入框例外，不然打不了字。 */
:root {
  --green: #2F6B4F; --green-2: #285C44; --on-green: #F6F3EC; --on-green-2: #EEF3EF; --on-green-3: #D6E3DA;
  --paper: #F6F3EC; --paper-2: #ECE6D8; --sheet: #FFFDF7; --ink: #231F1C; --ink-2: #3A3430; --ink-3: #6A6058;
  --yellow: #F4CD55; --hl: #F4CD55; --rule: rgba(35,31,28,.28);
  --win: #2F6B4F; --lose: #B8412E;
  --shadow: rgba(0,0,0,.16);
  --f-hand: "LM Hand", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --f-body: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --tw: clamp(30px, calc((100vw - 60px) / 9), 46px); /* 手牌一張的寬：390 寬一行 9 張 */
  --tw-s: clamp(19px, calc((100vw - 110px) / 12), 26px); /* 牌河小牌 */
  --tab-h: 64px;
  --edges: url(/img/ui/edge-top.svg) top / 100% 5px no-repeat, url(/img/ui/edge-bottom.svg) bottom / 100% 5px no-repeat,
           url(/img/ui/edge-left.svg) left / 5px 100% no-repeat, url(/img/ui/edge-right.svg) right / 5px 100% no-repeat;
  color-scheme: only light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #1D4533; --green-2: #173828; --on-green: #EDE8DD; --on-green-2: #E4ECE6; --on-green-3: #C6D5CB;
    --paper: #191814; --paper-2: #24221C; --sheet: #23211B; --ink: #EDE8DD; --ink-2: #D8D2C7; --ink-3: #A9A094;
    --hl: rgba(244,205,85,.32); --rule: rgba(237,232,221,.3); --win: #7CC39C; --lose: #F08A74; --shadow: rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --green: #1D4533; --green-2: #173828; --on-green: #EDE8DD; --on-green-2: #E4ECE6; --on-green-3: #C6D5CB;
  --paper: #191814; --paper-2: #24221C; --sheet: #23211B; --ink: #EDE8DD; --ink-2: #D8D2C7; --ink-3: #A9A094;
  --hl: rgba(244,205,85,.32); --rule: rgba(237,232,221,.3); --win: #7CC39C; --lose: #F08A74; --shadow: rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 17px; line-height: 1.75; overflow-x: hidden; overflow-x: clip; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(640px, 100% - 32px); }
h1, h2, h3, .f-hand { font-family: var(--f-hand); font-weight: 400; }
h1, h2, h3 { line-height: 1.3; }
.small { font-size: 14.5px; color: var(--ink-3); line-height: 1.7; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; }
.center { text-align: center; }
.center img { margin-inline: auto; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
[hidden] { display: none !important; }
.loading { color: var(--ink-3); padding: 24px 0; }

/* 解鎖前後顯示不同東西（html.is-unlocked 由頁首小程式依通行證加上） */
.is-unlocked [data-locked-only] { display: none !important; }
html:not(.is-unlocked) [data-unlocked-only] { display: none !important; }

/* ── 手繪零件：線與框用 mask 疊文字色，深色模式自動對 ── */
.ic { flex: none; }
.sec-h { font-size: 30px; margin: 0 0 6px; position: relative; display: inline-block; padding-bottom: 8px; }
.sec-h::after { content: ""; position: absolute; left: -4px; right: -8px; bottom: 0; height: 12px; background: var(--yellow); -webkit-mask: url(/img/ui/underline.svg) center / 100% 100% no-repeat; mask: url(/img/ui/underline.svg) center / 100% 100% no-repeat; }
.hr { height: 14px; background: var(--rule); -webkit-mask: url(/img/ui/divider.svg) center / 100% 100% no-repeat; mask: url(/img/ui/divider.svg) center / 100% 100% no-repeat; margin: 28px 0; border: 0; }
.sheet { position: relative; background: var(--sheet); color: var(--ink); box-shadow: 5px 7px 0 var(--shadow); padding: 20px 18px; }
/* 手繪框：四條邊各自固定粗細（整個框一起拉伸的話，線會跟著變粗） */
.sheet::before, .stop::before, .btn-ghost::before { content: ""; position: absolute; inset: 0; background: var(--ink); opacity: .85; -webkit-mask: var(--edges); mask: var(--edges); pointer-events: none; }
.tape { position: absolute; width: 84px; height: 22px; background: rgba(244,205,85,.85); top: -11px; left: calc(50% - 42px); transform: rotate(-4deg); }

/* 角色貼紙：白邊＋硬影子（美術組的角色是透明底，白邊由這裡加，跟官網一樣） */
.st { filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(3px 5px 0 rgba(0,0,0,.18)); }

/* ── 按鈕：黃底手寫字、硬影子、微微歪（跟官網一樣），手機上至少 52px 高 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 8px 22px 10px; font-family: var(--f-hand); font-size: 22px; line-height: 1.2; text-decoration: none; border: 0; cursor: pointer; color: #231F1C; background: var(--yellow); box-shadow: 4px 5px 0 rgba(0,0,0,.25); transform: rotate(-1deg); position: relative; -webkit-user-select: none; user-select: none; }
.btn:active { transform: rotate(-1deg) translate(3px, 4px); box-shadow: 1px 1px 0 rgba(0,0,0,.25); }
.btn-big { width: 100%; font-size: 26px; min-height: 60px; }
.btn-ghost { background: transparent; color: inherit; box-shadow: none; transform: none; }
.btn-ghost::before { background: currentColor; opacity: 1; }
.btn-ghost:active { transform: translate(1px, 2px); box-shadow: none; }
.btn.is-off, .btn:disabled { background: var(--paper-2); color: var(--ink-3); box-shadow: none; cursor: not-allowed; }
.btn-plain { background: none; border: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.buy { display: grid; gap: 14px; margin: 20px 0 0; }
.buy .small { margin: 0; }
@media (min-width: 560px) { .buy { grid-template-columns: auto auto; justify-content: start; } .buy .small { grid-column: 1 / -1; } }

/* ── 綠底頁首 ── */
.green { background: var(--green); color: var(--on-green); }
.top { position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-hand); font-size: 24px; text-decoration: none; }
.brand-logo { height: 34px; width: auto; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.h1-logo { width: min(330px, 86vw); height: auto; display: block; }
.brand-head { width: 40px; height: 40px; border-radius: 50%; background: #F6F3EC; object-fit: cover; }
.top-key { font-family: var(--f-hand); font-size: 18px; background: var(--yellow); color: #231F1C; text-decoration: none; padding: 6px 14px 8px; transform: rotate(2deg); box-shadow: 3px 3px 0 rgba(0,0,0,.25); }
.nav-desk { display: none; }

/* ── 底部分頁列（手機）：像 LINE 那樣，拇指點得到 ── */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 0 var(--rule); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: var(--tab-h); text-decoration: none; font-size: 14px; line-height: 1.2; color: var(--ink-3); position: relative; }
.tabbar a[aria-current] { color: var(--ink); font-weight: 700; }
.tabbar a[aria-current]::before { content: ""; position: absolute; top: 5px; width: 44px; height: 34px; background: var(--yellow); opacity: .55; border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; z-index: -1; }
body.focus .tabbar { display: none; }
body.focus { padding-bottom: env(safe-area-inset-bottom); }

/* ── 首頁 ── */
.hero { padding: 26px 0 36px; overflow: hidden; }
.hero-in { display: grid; gap: 8px; }
.kicker { margin: 0; color: var(--on-green-3); font-size: 15px; }
.hero h1 { margin: 4px 0 12px; }
.h1-sub { display: block; font-size: 26px; margin-top: 10px; }
.h1-sub em { font-style: normal; color: #231F1C; background: var(--yellow); padding: 0 .2em .06em; display: inline-block; transform: rotate(-2deg); box-shadow: .1em .12em 0 rgba(0,0,0,.2); }
.lead { font-size: 18px; color: var(--on-green-2); margin: 0 0 20px; }
.hero-art { display: flex; justify-content: center; margin-top: 10px; }
.hero-pic { width: min(300px, 80vw); height: auto; }
.block { padding: 34px 0 10px; }
.sub { color: var(--ink-2); margin: 4px 0 18px; }
.chapters { display: grid; gap: 18px; }
.chapter .ch-title { font-size: 22px; margin: 0 0 6px; display: flex; align-items: baseline; gap: 10px; }
.ch-no { font-size: 15px; font-family: var(--f-body); color: var(--ink-3); }
.rules { list-style: none; margin: 0; padding: 0; }
.rules a, .stop-rules a { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 4px; text-decoration: none; border-bottom: 1.5px dashed var(--rule); }
.rules .no, .stop-rules .no { flex: none; width: 34px; height: 34px; display: grid; place-items: center; font-size: 20px; color: #231F1C; background: var(--yellow); border-radius: 50% 44% 52% 46% / 48% 54% 46% 52%; transform: rotate(-6deg); }
.rules .chant, .stop-rules .chant { flex: 1; font-size: 18px; line-height: 1.45; }
.free { flex: none; font-size: 13px; background: var(--green); color: var(--on-green); padding: 2px 8px; }
.lock { flex: none; color: var(--ink-3); }
.badge-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 12px; }
.badge-list li { display: grid; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; width: fit-content; font: inherit; font-size: 14.5px; font-weight: 700; padding: 2px 10px; border: 2px solid currentColor; background: var(--sheet); color: var(--ink); cursor: default; line-height: 1.5; transform: rotate(-1.5deg); }
button.badge { cursor: pointer; }
.b-exact { color: #2F6B4F; } .b-model { color: #3B6EA5; } .b-exp { color: #9C5B34; }
:root[data-theme="dark"] .b-exact { color: #7CC39C; } :root[data-theme="dark"] .b-model { color: #8DB3DE; } :root[data-theme="dark"] .b-exp { color: #D9A27E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b-exact { color: #7CC39C; } :root:not([data-theme="light"]) .b-model { color: #8DB3DE; } :root:not([data-theme="light"]) .b-exp { color: #D9A27E; } }
.gets { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 20px; }
.gets li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.gets li:nth-child(2n) { transform: rotate(.5deg); }
.gets li:nth-child(2n+1) { transform: rotate(-.4deg); }
.gets h3 { margin: 0 0 2px; font-size: 22px; }
.gets p { margin: 0; font-size: 16px; }

/* ── 口訣頁 ── */
.rule-hero { padding: 18px 0 26px; }
.crumb { margin: 0 0 8px; font-size: 14.5px; color: var(--on-green-3); }
.crumb a { text-underline-offset: 4px; }
.rule-no { margin: 0; font-size: 20px; color: var(--yellow); }
.chant-big { font-size: clamp(34px, 9vw, 54px); line-height: 1.25; margin: 4px 0 14px; }
.rule-badge { margin: 0; }
.rule-top { display: grid; gap: 14px; }
.rule-pic { width: min(240px, 64vw); height: auto; margin: 0 auto; }
.summary { font-size: 19px; line-height: 1.85; margin: 0; }
.detail { margin-top: 18px; }
.body-text p { font-size: 17.5px; line-height: 1.9; margin: 0 0 14px; }
.numbers { margin: 22px 0; }
.numbers h2 { font-size: 22px; margin: 0 0 6px; }
.numbers ul { margin: 0; padding-left: 1.1em; }
.practice-btn { margin: 26px 0 8px; }
.rule-nav { display: flex; justify-content: space-between; gap: 12px; margin: 26px 0 0; }
.rule-nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; text-decoration: none; font-size: 16px; color: var(--ink-2); }
.locked { margin: 22px 0 8px; text-align: center; padding-top: 12px; }
.locked .lock-st { width: 110px; height: auto; margin: 0 auto; }
.locked h2 { font-size: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; }
.locked p { margin: 0 0 6px; }
.locked .buy { justify-content: center; }
.talk-inline { display: inline-block; background: var(--paper); border: 2px solid var(--ink); padding: 2px 12px 4px; font-size: 18px; transform: rotate(-2deg); margin: 0; }

/* 術語：第一次出現加虛線底線，點了看解釋 */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: help; text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-color: var(--green); }
.pop { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); z-index: 50; background: #F6F3EC; color: #231F1C; border: 2px solid #231F1C; box-shadow: 4px 5px 0 rgba(0,0,0,.25); padding: 12px 16px 14px; font-size: 16.5px; line-height: 1.7; max-width: 520px; margin-inline: auto; }
.pop b { font-size: 18px; display: block; padding-right: 40px; }
.pop-x { position: absolute; top: 2px; right: 2px; color: #231F1C; }
body.focus .pop { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* ── 牌 ── */
.t { position: relative; display: inline-block; flex: none; width: var(--tw); aspect-ratio: 3 / 4; background: url(/tiles/front.svg) center / 100% 100% no-repeat; border-radius: 4px; box-shadow: 0 3px 0 #B8AE9C; padding: 0; border: 0; margin: 0; vertical-align: bottom; }
.t img { width: 100%; height: 100%; }
.t[data-code="z5"]::after { content: ""; position: absolute; inset: 20% 24%; border: 2px solid #3B6EA5; border-radius: 2px; }
.t-s { width: var(--tw-s); border-radius: 3px; box-shadow: 0 2px 0 #B8AE9C; }
.t-xs { width: 22px; border-radius: 2px; box-shadow: 0 1.5px 0 #B8AE9C; }
button.t { cursor: pointer; }

.board { margin: 12px 0 0; }
.board-lab { margin: 0 0 6px; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.turn { margin-left: auto; font-size: 14px; }
.rivers-box { background: var(--green); color: var(--on-green); padding: 10px 10px 12px; box-shadow: 4px 5px 0 var(--shadow); }
.rivers-box .board-lab { color: var(--on-green-3); }
.rivers { display: grid; gap: 6px; }
.river-row { display: grid; grid-template-columns: 44px 1fr; gap: 6px; align-items: start; }
.river-row.me { border-top: 1.5px dashed rgba(246,243,236,.35); padding-top: 6px; }
.seat { font-size: 14px; line-height: 1.3; padding-top: 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.dealer { font-style: normal; font-size: 12px; background: var(--yellow); color: #231F1C; padding: 0 5px; transform: rotate(-4deg); }
.river { display: flex; flex-wrap: wrap; gap: 3px 2px; align-items: flex-end; min-height: calc(var(--tw-s) * 4 / 3); }
.none { font-size: 13px; color: var(--on-green-3); align-self: center; }
.shown { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
.shown-lab { font-size: 13px; }
.meld { display: inline-flex; gap: 1px; padding: 2px; background: rgba(244,205,85,.3); }
.offer { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 4px; font-family: var(--f-hand); font-size: 22px; }
.hand-lab { margin-top: 14px; }
.tap-hint { font-size: 14px; background: var(--yellow); color: #231F1C; padding: 0 8px; transform: rotate(-2deg); }
.my-melds { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.hand { display: flex; flex-wrap: wrap; gap: 10px 8px; align-items: flex-end; padding: 10px 0 6px; }
.suit-group { display: inline-flex; flex-wrap: wrap; gap: 5px 2px; }
.drawn-wrap { display: inline-flex; flex-direction: column; align-items: center; margin-left: 6px; }
.drawn-lab { font-size: 12px; color: var(--ink-3); line-height: 1.2; }
.t.opt { box-shadow: 0 3px 0 #B8AE9C, 0 0 0 3px var(--yellow); transform: translateY(-6px); }
.t.opt.pick:active { transform: translateY(-2px); }
.board.answered .t.opt { transform: none; }
.t.is-picked { box-shadow: 0 0 0 3px var(--lose); }
.t.is-answer { box-shadow: 0 0 0 3px var(--win), 0 3px 0 #B8AE9C; transform: translateY(-6px); }
@media (prefers-reduced-motion: no-preference) {
  .board:not(.answered) .t.opt { animation: 等你 2.4s ease-in-out infinite; }
  .board:not(.answered) .suit-group .t.opt:nth-of-type(2n) { animation-delay: .3s; }
  @keyframes 等你 { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(-9px); } }
}
.call-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 0; }
.btn-call { font-size: 28px; min-height: 60px; }
.btn-call:nth-child(2) { background: var(--sheet); color: var(--ink); }

/* 答案區 */
.q { margin: 10px 0 0; }
.prompt { font-size: 19px; line-height: 1.6; margin: 0 0 4px; font-weight: 700; }
.reveal { margin-top: 14px; }
.verdict { font-family: var(--f-hand); font-size: 26px; margin: 0 0 8px; }
.facts { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.facts li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 8px 10px; background: var(--paper-2); font-size: 16px; line-height: 1.55; }
.facts li.is-answer { background: rgba(47,107,79,.14); outline: 2px solid var(--win); }
.facts li.is-picked { outline: 2px dashed var(--lose); }
.facts .act { font-family: var(--f-hand); font-weight: 400; font-size: 20px; min-width: 2.4em; text-align: center; }
.explain { font-size: 17px; line-height: 1.85; margin: 8px 0; }
.truth { background: var(--paper-2); border-left: 4px solid var(--lose); padding: 8px 12px; margin: 0 0 10px; font-size: 16px; line-height: 1.6; }
.truth p { margin: 0; }
.truth-tiles { display: flex; gap: 4px; margin-top: 6px !important; }
.note { font-size: 14.5px; color: var(--ink-3); margin: 0 0 8px; }
.q-badge { margin: 4px 0 8px; }
.check summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 15.5px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; }
.check p { margin: 0 0 8px; font-size: 15.5px; }
.q-example { margin-top: 8px; }

/* ── 練習（一次一題） ── */
.runner-wrap { padding: 12px 0 30px; max-width: 760px; }
.run-top { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.run-exit { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; min-width: 44px; color: var(--ink-2); text-decoration: none; font-size: 15px; }
.run-title { flex: 1; min-width: 0; font-size: 15px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 6px; }
.dots i { width: 14px; height: 14px; border: 2px solid var(--ink-3); border-radius: 50% 45% 55% 48%; }
.dots i.ok { background: var(--win); border-color: var(--win); }
.dots i.ng { background: var(--lose); border-color: var(--lose); }
.dots i.now { border-color: var(--ink); transform: scale(1.15); }
.coach { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; margin: 4px 0 6px; }
.coach img { width: 76px; height: auto; }
.bubble { position: relative; background: var(--sheet); color: var(--ink); border: 2px solid var(--ink); padding: 8px 12px; box-shadow: 3px 4px 0 var(--shadow); font-size: 17px; line-height: 1.5; font-weight: 700; }
.bubble::before { content: ""; position: absolute; left: -9px; top: 50%; width: 14px; height: 14px; background: var(--sheet); border: solid var(--ink); border-width: 0 0 2px 2px; transform: translateY(-50%) rotate(45deg); }
.bubble .say { display: block; font-family: var(--f-hand); font-weight: 400; font-size: 19px; color: var(--ink-3); }
.feedback { margin: 16px 0 0; }
.fb-head { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.fb-head img { width: 96px; height: auto; }
.fb-title { font-family: var(--f-hand); font-size: 34px; line-height: 1.1; margin: 0; }
.fb-title.ok { color: var(--win); }
.fb-title.ng { color: var(--lose); }
.fb-sub { margin: 4px 0 0; font-size: 16.5px; }
.run-next { margin: 18px 0 0; }
.result { text-align: center; padding: 10px 0; }
.result .cheer { width: 160px; height: auto; margin: 0 auto; }
.result h1 { font-size: 40px; margin: 2px 0 6px; }
.result .res-rule { font-size: 15.5px; color: var(--ink-3); margin: 8px 0 0; }
.big-stars { display: flex; justify-content: center; gap: 6px; margin: 8px 0; }
.big-stars .star { width: 58px; height: 58px; }
.big-stars .star:nth-child(2) { transform: translateY(-10px); }
.result p { margin: 4px 0; font-size: 18px; }
.result .btns { display: grid; gap: 14px; margin: 22px 0 0; }
.new-badge { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 14px auto 0; max-width: 360px; text-align: left; }
.new-badge img { width: 72px; height: auto; }

/* ── 闖關地圖 ── */
.play-head { padding: 18px 0 20px; }
.play-head h1 { font-size: 36px; margin: 0 0 8px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { display: inline-flex; align-items: center; gap: 6px; margin: 0; background: rgba(246,243,236,.12); padding: 6px 12px; font-size: 15px; color: var(--on-green); text-decoration: none; min-height: 44px; }
.stat b { font-size: 24px; line-height: 1; }
.stat-link { background: var(--yellow); color: #231F1C; }
.play-rule { margin: 10px 0 0; font-size: 15px; color: var(--on-green-3); line-height: 1.6; }
.map-wrap { max-width: 480px; margin: 0 auto; padding: 6px 0 0; overflow: hidden; }
.map-board { position: relative; width: 100%; }
.map-bg { width: 100%; height: 100%; }
.node { position: absolute; transform: translate(-50%, -50%); aspect-ratio: 1; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.node-pic { width: 80%; height: auto; }
.node-label { position: absolute; top: 50%; transform: translateY(-50%) rotate(-1.5deg); width: max-content; max-width: 150px; display: grid; gap: 0; text-align: left; line-height: 1.25; background: var(--sheet); padding: 6px 10px 7px; box-shadow: 3px 4px 0 var(--shadow); }
.node-r { left: 104%; }
.node-l { right: 104%; text-align: right; justify-items: end; transform: translateY(-50%) rotate(1.5deg); }
.node-no { font-size: 15px; color: var(--ink-3); }
.node-title { font-size: 21px; color: var(--ink); }
.node-stars { display: flex; gap: 1px; font-size: 13px; color: var(--ink-3); align-items: center; min-height: 20px; }
.node-label .free { justify-self: start; margin-top: 2px; }
.node-l .free { justify-self: end; }
.node.is-locked .node-pic { filter: grayscale(1); opacity: .55; }
.node.is-next::before { content: ""; position: absolute; inset: -7%; border-radius: 50%; border: 4px solid var(--yellow); }
.node .next-flag { position: absolute; top: -26%; left: 50%; transform: translateX(-50%) rotate(-3deg); white-space: nowrap; background: var(--yellow); color: #231F1C; font-family: var(--f-hand); font-size: 18px; padding: 2px 10px 4px; box-shadow: 3px 3px 0 rgba(0,0,0,.2); z-index: 2; }
@media (prefers-reduced-motion: no-preference) {
  .node.is-next::before { animation: 呼吸 1.8s ease-in-out infinite; }
  @keyframes 呼吸 { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: .6; } }
}
.sheet-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,.4); }
.ch-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom)); z-index: 45; max-height: min(72vh, 560px); overflow: auto; padding: 16px 16px 14px; max-width: 560px; margin-inline: auto; }
.ch-sheet .stop-no { margin: 0; font-size: 16px; color: var(--ink-3); }
.ch-sheet .stop-title { margin: 0 0 2px; font-size: 28px; padding-right: 40px; }
.ch-sheet .small { margin: 0 0 4px; }
.sheet-close { position: absolute; top: 8px; right: 8px; z-index: 2; }
.sheet-lock { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 15px; margin: 10px 0 0; padding: 8px 10px; background: var(--paper-2); }
.stop-no { margin: 0; }
.stop-rules { list-style: none; margin: 6px 0 0; padding: 0; }
.stop-rules li:last-child a { border-bottom: 0; }
.stop-rules .chant { font-size: 17px; }
.stars { display: inline-flex; gap: 1px; color: var(--ink-3); flex: none; }
.star.on { color: var(--ink); }
.concept .tag { font-size: 13px; color: var(--ink-3); flex: none; }
.badges { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
.badges li { display: grid; justify-items: center; text-align: center; gap: 2px; }
.badges img { width: 72px; height: auto; }
.badges li:not(.got) img { opacity: .45; filter: grayscale(1); }
.badges b { font-size: 16px; }
.badges span { font-size: 13.5px; color: var(--ink-3); line-height: 1.5; }

/* ── 工具頁共用 ── */
.page-h { font-size: 38px; margin: 0; }
.app-page .sub { margin-bottom: 14px; }
#add-btn + form + .sub, #add-btn ~ .sub { margin-top: 18px; }
.field { display: grid; gap: 6px; margin: 0 0 16px; }
.field-lab { margin: 0 0 -4px; font-size: 16px; font-weight: 700; }
.field > span, .form label { font-size: 16px; font-weight: 700; }
input[type="text"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
  width: 100%; min-height: 52px; font: inherit; font-size: 20px; padding: 8px 12px; color: var(--ink); background: var(--sheet); border: 2px solid var(--ink); border-radius: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg button { min-height: 56px; font-family: var(--f-hand); font-size: 24px; background: var(--sheet); color: var(--ink); border: 2px solid var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"].win { background: var(--win); border-color: var(--win); color: #fff; }
.seg button[aria-pressed="true"].lose { background: var(--lose); border-color: var(--lose); color: #fff; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -.01em; }
.pos { color: var(--win); }
.neg { color: var(--lose); }
.zero { color: var(--ink-3); }
.form .msg { margin: 10px 0 0; min-height: 1.6em; font-weight: 700; }
.form .msg.err { color: var(--lose); }
.form .msg.ok { color: var(--win); }
.form { display: grid; gap: 12px; }
.warn { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; background: var(--paper-2); padding: 12px 14px; font-size: 15.5px; line-height: 1.7; margin: 18px 0; }
.warn a { font-weight: 700; }

/* 日記 */
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 18px; }
.dash .today { grid-column: 1 / -1; }
.tile-num { padding: 14px 14px 12px; }
.tile-num .lab { font-family: var(--f-hand); font-size: 20px; margin: 0; color: var(--ink-2); }
.tile-num .val { margin: 2px 0 0; font-size: 30px; line-height: 1.15; }
.tile-num.today .val { font-size: 44px; }
.tile-num .unit { font-size: .5em; font-weight: 700; margin-left: 2px; }
.tile-num .hint { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-3); }
.chart { margin: 26px 0 20px; }
.chart h2, .list-h { font-size: 22px; margin: 0 0 4px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .bar-pos { fill: var(--win); }
.chart .bar-neg { fill: var(--lose); }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--f-body); }
.entries { list-style: none; padding: 0; margin: 6px 0 0; }
.entries li { display: grid; grid-template-columns: 1fr auto 44px; gap: 8px; align-items: center; min-height: 58px; border-bottom: 1.5px dashed var(--rule); }
.entries .d { font-size: 15px; color: var(--ink-3); line-height: 1.3; }
.entries .n { display: block; font-size: 16px; color: var(--ink); overflow-wrap: anywhere; }
.entries .money { font-size: 21px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: var(--ink-3); cursor: pointer; }
.month-h { font-size: 15px; color: var(--ink-3); margin: 16px 0 0; }
.sample-note { position: absolute; top: -12px; right: 10px; background: var(--yellow); color: #231F1C; font-family: var(--f-hand); font-size: 18px; padding: 2px 10px 4px; transform: rotate(4deg); box-shadow: 3px 3px 0 rgba(0,0,0,.2); z-index: 2; }
.demo { position: relative; margin: 10px 0 20px; padding-top: 6px; }
.demo .demo-body { pointer-events: none; }
.add-panel { margin: 0 0 20px; }
.add-panel h2 { font-size: 26px; margin: 0 0 12px; }
.unit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; color: var(--ink-2); }

/* 結算 */
.players { display: grid; gap: 14px; margin: 0 0 14px; }
.player { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 14px; }
.player-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player-row .field { margin: 0; }
.player-row input { font-size: 19px; padding: 8px 10px; }
.player .seg button { min-height: 50px; font-size: 21px; }
.balance { font-size: 17px; font-weight: 700; margin: 0 0 14px; padding: 10px 12px; background: var(--paper-2); }
.balance.ok { color: var(--win); }
.balance.ng { color: var(--lose); }
.transfers { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 12px; }
.transfers li { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 14px 12px; font-size: 20px; text-align: center; }
.transfers .who { font-weight: 700; overflow-wrap: anywhere; }
.transfers .arrow { display: grid; justify-items: center; font-size: 22px; }
.transfers .arrow .money { font-size: 22px; color: var(--ink); }
.transfers .give { font-size: 14px; color: var(--ink-3); }

/* 備份 */
.backup-card { margin: 0 0 22px; }
.backup-card h2 { font-size: 24px; margin: 0 0 6px; }
.backup-card p { margin: 0 0 12px; }
.counts { margin: 0 0 12px; padding-left: 1.2em; }
input[type="file"] { font-size: 16px; }

/* 速查卡 */
.card-sheet { position: relative; background: #FFFDF7; color: #231F1C; padding: 22px 18px 16px; box-shadow: 6px 8px 0 rgba(0,0,0,.18); margin: 16px 0 22px; overflow: hidden; }
.card-title { font-size: 26px; margin: 0 0 8px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.card-title img { width: 150px; height: auto; }
.card-ch { margin: 0 0 10px; }
.card-ch-t { margin: 0; font-size: 14px; font-weight: 700; color: #2F6B4F; border-bottom: 1.5px dashed rgba(35,31,28,.28); }
.card-line { margin: 4px 0; font-size: 17px; line-height: 1.5; display: grid; grid-template-columns: 26px 1fr; }
.card-line .no { font-weight: 800; color: #6A6058; }
.card-foot { margin: 10px 0 0; text-align: center; font-size: 13px; color: #6A6058; }
.card-wm { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-family: var(--f-hand); font-size: 90px; color: rgba(184,65,46,.18); transform: rotate(-18deg); pointer-events: none; }
.card-actions { display: grid; gap: 14px; }

/* 解鎖、條款 */
.form label { margin-top: 4px; }
.legal h2 { font-size: 24px; margin: 26px 0 4px; }
.legal p { margin: 0 0 12px; }

/* 頁尾 */
.foot { background: var(--green); color: var(--on-green-3); padding: 20px 0 26px; margin-top: 50px; font-size: 14.5px; line-height: 1.8; }
.foot p { margin: 0 0 8px; }
.foot .small { color: var(--on-green-3); }
.foot .links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot .links a { display: inline-flex; align-items: center; min-height: 36px; }
body.focus .foot { display: none; }

/* 小提示（拿到徽章、存好了） */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) rotate(-1deg); z-index: 60; background: var(--yellow); color: #231F1C; padding: 10px 18px 12px; font-weight: 700; font-size: 17px; line-height: 1.5; box-shadow: 4px 5px 0 rgba(0,0,0,.25); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); }
.toast img { width: 44px; height: auto; }
body.focus .toast { bottom: calc(18px + env(safe-area-inset-bottom)); }

/* ================= 電腦版 ================= */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .nav-desk { display: flex; gap: 22px; margin-left: auto; font-size: 16px; }
  .nav-desk a { text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
  .nav-desk a[aria-current], .nav-desk a:hover { text-decoration: underline; text-underline-offset: 6px; }
  .hero { padding: 48px 0 56px; }
  .hero-in { grid-template-columns: minmax(0, 1fr) 360px; align-items: center; gap: 40px; }
  .hero .btn-big { width: auto; padding-inline: 34px; }
  .h1-logo { width: 470px; }
  .h1-sub { font-size: 34px; }
  .chapters { grid-template-columns: 1fr 1fr; gap: 26px 40px; }
  .gets { grid-template-columns: 1fr 1fr; }
  .rule-top { grid-template-columns: 240px 1fr; align-items: center; gap: 30px; }
  .rule-body { max-width: 860px; }
  .practice-btn { width: auto; padding-inline: 40px; }
  .ch-sheet { bottom: 24px; }
  .badges { grid-template-columns: repeat(4, 1fr); }
  .players { grid-template-columns: 1fr 1fr; }
  .app-page { max-width: 820px; }
  .runner-wrap { max-width: 900px; }
  .pop, .toast, body.focus .pop { bottom: 24px; }
  .card-sheet { max-width: 520px; }
  .card-actions { grid-template-columns: auto auto; justify-content: start; }
}

@media print {
  .top, .tabbar, .foot, .card-actions, .page-h, .sub { display: none !important; }
  .card-sheet { box-shadow: none; max-width: none; }
}

/* 行內小圖示（跟文字排在同一行） */
svg.inline-ic { display: inline-block; vertical-align: -5px; margin-right: 4px; }
/* 跳到頁內錨點時，留出固定頁首的高度 */
[id] { scroll-margin-top: 76px; }
/* 強制深色（三星等）：牌改用 PNG（牌身已經合進去），拿掉會被壓暗的 CSS 牌身 */
html[data-forced-dark] .t { background: none; }

/* 還沒有題目的口訣 */
.soon { margin: 22px 0 6px; padding: 12px 14px; background: var(--paper-2); font-weight: 700; }
