/* [claude code] 2026-10-19 v0.2 英語小鎮的畫面樣式。
   🔴 守門(tools/check_ui.py):字級只用 11 / 13 / 15 / 20 / 28(輸入框 16)· 圓角只用 8 / 14 / 999 · 顏色只用 theme.css 的變數 · grid 用 minmax(0, 1fr)。
   可點的東西至少 44px 高;版面以 375px 寬為準。 */

/* 🔴 有 display 的元素會蓋掉 hidden 屬性(跟讀的句子、單字本的細節都中過)→ 一律強制藏起來 */
[hidden] { display: none !important; }

/* ── 登入 ─────────────────────────────────────────────── */
#gate { align-items: stretch; text-align: center; background: linear-gradient(var(--bg-2), var(--bg)); }
.gate-logo { font-size: 28px; width: 72px; height: 72px; margin: 0 auto; display: grid; place-items: center; border-radius: 999px; background: var(--surface); box-shadow: 0 4px 12px var(--shadow); }
img.gate-logo { display: block; width: 96px; height: 96px; border-radius: 14px; object-fit: cover; }
.gate-pane { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.gate-pane[hidden] { display: none; }
.gate-pane h2 { font-size: 20px; }
button.big { min-height: 56px; font-size: 20px; }
button.small { font-size: 13px; min-height: 44px; color: var(--mute); }
#gate-msg { min-height: 20px; color: var(--danger); }
.gate-link { font-size: 11px; color: var(--mute); }

/* ── 上方 HUD ─────────────────────────────────────────── */
#hud { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) 12px 4px; background: var(--surface); border-bottom: 1px solid var(--border); }
.hud-me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 0 4px; justify-content: flex-start; }
.hud-avatar { width: 36px; height: 36px; flex: none; }
.hud-nick { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 15px; }
.hud-pill.streak { color: var(--mute); }
.hud-pill.streak.lit { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.coin-ic { display: inline-block; width: 16px; height: 16px; border-radius: 999px; background: radial-gradient(circle at 35% 35%, var(--accent-2), var(--gold)); box-shadow: inset 0 0 0 2px var(--gold); }
.pill-ic { font-size: 15px; }

/* 頭像 / 佔位圖 */
.av, .hud-av { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 999px; background: var(--bg-2); font-size: 20px; overflow: hidden; }
.sprite-img { object-fit: contain; }
.av.sprite-img, .hud-av.sprite-img { object-fit: cover; }

/* ── 分頁內容 ─────────────────────────────────────────── */
#view { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 12px; }
#view[data-tab="town"] { padding: 0; gap: 0; overflow: hidden; }
.loading { text-align: center; color: var(--mute); padding: 24px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px var(--shadow); }
.card h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card .sub { font-size: 13px; color: var(--mute); }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-row > .grow { flex: 1; min-width: 0; }
.tag { display: inline-flex; align-items: center; padding: 0 8px; min-height: 20px; border-radius: 999px; font-size: 11px; background: var(--bg-2); color: var(--text); }
.tag.teal { background: var(--teal-soft); color: var(--teal); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.big-num { font-size: 28px; font-weight: 800; line-height: 1.1; }
.mute { color: var(--mute); }

/* 首頁:目標環 */
.goal-card { flex-direction: row; align-items: center; gap: 16px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--bg-2); }
.ring .bar { stroke: var(--accent); transition: stroke-dashoffset .6s; }
.ring.done .bar { stroke: var(--good); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 28px; line-height: 1; }
.ring-text small { font-size: 11px; color: var(--mute); }
.goal-side { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.goal-side .streak-line { font-size: 20px; font-weight: 700; color: var(--accent); }
.next-card { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--ink); }
.next-card .sub { color: var(--white-70); }
.next-card h3 { font-size: 20px; }
.next-card button.primary { background: var(--surface); color: var(--accent); border-color: var(--surface); min-height: 52px; font-size: 20px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick { align-items: flex-start; text-align: left; min-height: 96px; border: none; }
.quick .q-ic { font-size: 28px; line-height: 1; }
.quick b { font-size: 15px; }

/* ── 小鎮 ─────────────────────────────────────────────── */
.town { position: relative; height: 100%; overflow: hidden; background: var(--grass); }
.town-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }
.town-world { position: relative; width: 100%; }
.town canvas { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; }
.town-hud { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 3; display: flex; gap: 8px; pointer-events: none; }
.town-hud .hud-pill { background: var(--surface); box-shadow: 0 2px 6px var(--shadow); }
.town-shop { position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: none; background: transparent; min-height: 44px; }
.town-shop .bld { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-size: 28px; border-radius: 14px; background: var(--dirt); box-shadow: inset 0 0 0 3px var(--road-edge); }
.town-shop .bld img { width: 100%; height: 100%; object-fit: contain; }
.town-shop .bld.art, .shop-head .bld.art { background: none; box-shadow: none; }
.town-shop.open .bld.art { filter: drop-shadow(0 0 6px var(--glow)); }
.town-shop .bld .bld-emoji { font-size: 28px; }
.town-shop.locked .bld { filter: grayscale(1); opacity: .6; }
.town-shop.open .bld { background: var(--surface-2); box-shadow: inset 0 0 0 3px var(--accent-2), 0 4px 10px var(--shadow); }
.town-shop .plate { max-width: 140%; padding: 4px 8px; border-radius: 999px; background: var(--surface); box-shadow: 0 2px 6px var(--shadow); font-size: 13px; font-weight: 700; white-space: nowrap; }
.town-shop .state { font-size: 11px; padding: 0 8px; border-radius: 999px; background: var(--text); color: var(--ink); white-space: nowrap; }
.town-shop.buildable .state { background: var(--accent); }
.town-shop.open .state { background: var(--good); }
.town-shop.here .plate { box-shadow: 0 0 0 3px var(--accent), 0 2px 6px var(--shadow); }
.walker { position: absolute; z-index: 1; font-size: 20px; pointer-events: none; transition: top 4s linear, left 4s linear; }
.walker img { display: block; width: 28px; height: 35px; object-fit: contain; }

/* ── 店(面板)──────────────────────────────────────────── */
.shop-head { display: flex; align-items: center; gap: 12px; }
.shop-head .bld { width: 72px; height: 72px; flex: none; display: grid; place-items: center; font-size: 28px; border-radius: 14px; background: var(--bg-2); }
.shop-head .bld img { width: 100%; height: 100%; object-fit: contain; }
.shop-head h3 { font-size: 20px; }
.stage-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.stage-card .grow { flex: 1; min-width: 0; }
.stage-card .words { font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 15px; }
.stars .off { color: var(--border); }
.exam-part { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; border: 1px dashed var(--border); }
.exam-part.done { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.exam-part .grow { flex: 1; }

/* ── 先認識 / 玩法層共用 ─────────────────────────────────── */
.intro { display: flex; flex-direction: column; height: 100%; }
.intro-head, .qbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.intro-head h2, .qbar .title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.intro-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.word-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.word-grid.one { grid-template-columns: minmax(0, 1fr); }
.wcard { display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 64px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: left; }
.wcard .pic { width: 44px; height: 44px; flex: none; }
.wcard b { display: block; font-size: 15px; overflow-wrap: anywhere; }
.wcard small { display: block; font-size: 13px; color: var(--mute); }
.wcard.playing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--glow); }
.opt-pic { min-height: 96px; display: grid; place-items: center; padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.opt-pic .pic { width: 64px; height: 64px; }
.opt-pic .pic-emoji { transform: scale(1.6); }
.pic { display: grid; place-items: center; }
.pic-emoji { font-size: 28px; line-height: 1; }
.pic-letter { border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-weight: 800; font-size: 20px; }
.pic-zh { font-size: 15px; font-weight: 700; color: var(--text); text-align: center; line-height: 1.2; }
.pic-img { object-fit: contain; }
.game-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.game-pick button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 88px; padding: 8px 4px; }
.game-pick button .g-ic { font-size: 28px; line-height: 1; }
.game-pick button small { font-size: 11px; color: var(--mute); }
.game-pick button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--glow); }
.game-pick .rec { font-size: 11px; color: var(--accent); font-weight: 700; }
.intro-foot { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.intro-foot button { width: 100%; min-height: 56px; font-size: 20px; }

.qbar .q-prog { font-size: 13px; color: var(--mute); }
.qbar .bar { flex: 1; height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.qbar .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.qbar button { min-height: 40px; padding: 4px 12px; font-size: 13px; }
.stage-area { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.qfoot { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; justify-content: center; }
.flash-good { animation: flashGood .5s; }
.flash-bad { animation: shake .4s; }
@keyframes flashGood { 0% { box-shadow: 0 0 0 0 var(--good); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.feedback { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 5; padding: 8px 16px; border-radius: 999px; font-size: 20px; font-weight: 800; pointer-events: none; animation: pop .9s forwards; }
.feedback.good { background: var(--good); color: var(--ink); }
.feedback.bad { background: var(--danger); color: var(--ink); }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }
.coin-fly { position: absolute; z-index: 6; width: 20px; height: 20px; border-radius: 999px; background: radial-gradient(circle at 35% 35%, var(--accent-2), var(--gold)); pointer-events: none; animation: coinFly .7s forwards; }
@keyframes coinFly { 0% { opacity: 1; transform: translate(0, 0); } 100% { opacity: 0; transform: translate(0, -80px); } }

/* 擺攤 */
.shopg { display: flex; flex-direction: column; height: 100%; background: linear-gradient(var(--sky-2), var(--bg) 40%); }
.shopg .counter { position: relative; flex: none; padding: 12px; display: flex; align-items: flex-end; gap: 12px; min-height: 170px; }
.shopg .customer { font-size: 28px; width: 96px; height: 120px; flex: none; display: grid; place-items: end center; transition: transform .4s; }
.shopg .customer img { width: 96px; height: 120px; object-fit: contain; }
.shopg .customer.out { transform: translateX(-140%); }
.shopg .customer .sprite-emoji { font-size: 28px; transform: scale(2.4); transform-origin: bottom center; }
.bubble { position: relative; flex: 1; min-width: 0; padding: 12px; border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px var(--shadow); }
.bubble small { font-size: 11px; color: var(--mute); }
.bubble .say { display: flex; align-items: center; gap: 8px; }
.bubble .say b { flex: 1; min-width: 0; font-size: 20px; overflow-wrap: anywhere; }
.bubble .patience { height: 6px; margin-top: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.bubble .patience i { display: block; height: 100%; width: 100%; background: var(--good); transform-origin: left; }
.bubble .patience i.low { background: var(--danger); }
.icon-btn { min-width: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; border-radius: 999px; font-size: 20px; }
.icon-btn.teal { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.icon-btn.gold { background: var(--accent-2); border-color: var(--accent-2); }
.goods { flex: 1; min-height: 0; margin: 0 8px; padding: 8px; display: grid; gap: 8px; border-radius: 14px; background: var(--dirt); align-content: start; overflow-y: auto; }
.goods.pic12 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.goods.text { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.good-btn { aspect-ratio: 1; padding: 4px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--road-edge); }
.goods.text .good-btn { aspect-ratio: auto; min-height: 64px; font-size: 15px; }
.good-btn .pic { width: 80%; height: 80%; }
.good-btn .pic-emoji { font-size: 28px; transform: scale(1.5); }
.good-btn.right { border-color: var(--good); background: var(--good-soft); }
.good-btn.wrong { border-color: var(--danger); background: var(--danger-soft); }
.good-btn.gone { visibility: hidden; }

/* 說出來 */
.sayg { position: relative; height: 100%; display: flex; flex-direction: column; background: linear-gradient(var(--sky), var(--sky-2) 70%, var(--grass) 70%); }
.sky { position: relative; flex: 1; overflow: hidden; }
.faller { position: absolute; top: -110px; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 104px; margin-left: -52px; padding: 0; border: none; background: transparent; min-height: 44px; will-change: transform; }
.faller .pic { width: 64px; height: 64px; }
.faller .pic-emoji { font-size: 28px; transform: scale(1.6); }
.faller .label { padding: 4px 8px; border-radius: 999px; background: var(--surface); font-size: 15px; font-weight: 700; box-shadow: 0 2px 6px var(--shadow); max-width: 104px; overflow-wrap: anywhere; text-align: center; }
.faller.caught { transition: transform .5s, opacity .5s; opacity: 0; }
.faller.missed { opacity: .4; }
.say-foot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); }
.heard { min-height: 36px; padding: 4px 16px; border-radius: 999px; background: var(--teal); color: var(--ink); font-size: 15px; font-weight: 700; display: flex; align-items: center; }
.heard:empty { visibility: hidden; }
.mic { width: 88px; height: 88px; border-radius: 999px; font-size: 28px; background: var(--teal); border: 4px solid var(--surface); color: var(--ink); box-shadow: 0 4px 12px var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none; }
.mic.on { background: var(--danger); box-shadow: 0 0 0 8px var(--danger-soft); }
.mic-hint { font-size: 13px; color: var(--text); background: var(--white-70); padding: 2px 12px; border-radius: 999px; }
.basket { position: absolute; right: 12px; top: 8px; z-index: 3; }

/* 抓抓樂 */
.clawg { height: 100%; display: flex; flex-direction: column; background: linear-gradient(var(--mine-2), var(--mine)); color: var(--ink); }
.claw-top { display: flex; align-items: center; gap: 8px; padding: 12px; }
.claw-top .prompt { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 14px; background: var(--surface); color: var(--text); }
.claw-top .prompt small { display: block; font-size: 11px; color: var(--mute); }
.claw-top .prompt b { font-size: 20px; }
.claw-meters { display: flex; gap: 8px; padding: 0 12px; font-size: 13px; }
.meter { flex: 1; display: flex; align-items: center; gap: 4px; }
.meter .bar { flex: 1; height: 8px; border-radius: 999px; background: var(--mine); overflow: hidden; box-shadow: inset 0 0 0 1px var(--mine-2); }
.meter .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.claw-pit { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 24px 16px; align-content: center; }
.claw-arm { position: absolute; left: 50%; top: 0; width: 4px; height: 24px; background: var(--road-edge); transition: left .25s, height .25s; z-index: 2; }
.claw-arm::after { content: ''; position: absolute; left: -10px; bottom: -12px; width: 24px; height: 14px; border: 3px solid var(--road-edge); border-top: none; border-radius: 0 0 14px 14px; }
.gem { position: relative; aspect-ratio: 1; display: grid; place-items: center; padding: 8px; border-radius: 999px; background: radial-gradient(circle, var(--surface-2) 55%, var(--sky) 56%, var(--teal) 80%); border: 3px solid var(--gold); color: var(--text); }
.gem .pic { width: 60%; height: 60%; }
.gem .pic-emoji { transform: scale(2); }
.gem .gem-text { font-size: 15px; font-weight: 700; padding: 0 8px; text-align: center; }
.gem svg.timer { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.gem svg.timer circle { fill: none; stroke: var(--gold); stroke-width: 4; }
.gem.right { border-color: var(--good); box-shadow: 0 0 16px var(--good); }
.gem.wrong { border-color: var(--danger); opacity: .5; }
.gem.gone { visibility: hidden; }
.claw-pit.text { grid-template-columns: minmax(0, 1fr); }
.claw-pit.text .gem { aspect-ratio: auto; min-height: 64px; border-radius: 14px; background: var(--surface-2); overflow: hidden; }
.claw-pit.text .gem svg.timer { display: none; }
/* 文字寶石的倒數:底部一條會縮短的線(秒數由 quiz.js 設 --gem-ms) */
.claw-pit.text .gem::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 6px; height: 4px; border-radius: 999px; background: var(--gold); transform-origin: left; animation: gemBar var(--gem-ms, 7s) linear forwards; }
.claw-pit.text .gem.right::after, .claw-pit.text .gem.wrong::after { animation: none; transform: scaleX(0); }
@keyframes gemBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* 跟讀 */
.shadowg { height: 100%; display: flex; flex-direction: column; background: var(--bg); overflow-y: auto; }
.shadowg .qfoot { margin-top: auto; position: sticky; bottom: 0; }
.sentence-card { margin: 12px; padding: 16px; border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.sentence { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 20px; font-weight: 700; }
.tok { color: var(--text); transition: color .2s; }
.tok.hit { color: var(--good); }
.zh-line { font-size: 15px; color: var(--mute); }
.banner { margin: 0 12px; padding: 8px 12px; border-radius: 14px; text-align: center; font-weight: 700; }
.banner.good { background: var(--good); color: var(--ink); }
.banner.info { background: var(--bg-2); color: var(--text); }
.banner.bad { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px; }
.chip-btn { min-height: 44px; padding: 4px 12px; border-radius: 999px; font-size: 15px; }
.chip-btn.used { visibility: hidden; }
.built { min-height: 52px; margin: 0 12px; padding: 8px 12px; border-radius: 14px; border: 2px dashed var(--border); font-size: 20px; display: flex; flex-wrap: wrap; gap: 8px; }

/* 聽力 */
.listeng { height: 100%; display: flex; flex-direction: column; }
.dialog-lines { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.dline { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 14px; background: var(--surface); border: 2px solid transparent; text-align: left; }
.dline.right { flex-direction: row-reverse; text-align: right; background: var(--surface-2); }
.dline .who { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 999px; background: var(--bg-2); font-size: 20px; }
.dline .txt { min-width: 0; flex: 1; }
.dline .en { font-size: 15px; font-weight: 700; }
.dline .zh { font-size: 13px; color: var(--mute); }
.dline.now { border-color: var(--accent); }
.dline.blind .en, .dline.blind .zh { filter: blur(6px); }
.dline.blind.now .zh { filter: none; }
.player { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.player button { min-width: 44px; }
.player button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.quiz-q { display: flex; flex-direction: column; gap: 8px; }
.quiz-q b { font-size: 15px; }
.opt-list { display: grid; gap: 8px; }
.opt-list button { text-align: left; }
.opt-list button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); }

/* 情境對話 */
.talkg { height: 100%; display: flex; flex-direction: column; }
.chat { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--surface); box-shadow: 0 1px 4px var(--shadow); }
.msg.me { align-self: flex-end; background: var(--teal); color: var(--ink); }
.msg .en { font-size: 15px; font-weight: 700; }
.msg .zh { font-size: 13px; opacity: .8; }
.msg .tip { margin-top: 4px; font-size: 13px; color: var(--accent); }
.msg .msg-tools { display: flex; gap: 4px; margin-top: 4px; }
.msg .msg-tools button { min-height: 36px; padding: 0 8px; font-size: 13px; }
.msg.sys { align-self: center; background: var(--bg-2); box-shadow: none; font-size: 13px; }
.choices { display: grid; gap: 8px; padding: 8px 12px; }
.choice { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.choice small { font-size: 13px; color: var(--mute); }
.choice.bad { border-color: var(--danger); background: var(--danger-soft); }
.choice.locked { cursor: default; background: var(--surface-2); }
select { font: inherit; font-size: 16px; color: var(--text); min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); width: 100%; }
.hint-btn { white-space: nowrap; }
.chat-input { display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.chat-input input { flex: 1; }

/* 對話分頁 */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 999px; background: var(--bg-2); }
.seg button { border: none; border-radius: 999px; background: transparent; min-height: 40px; font-weight: 700; }
.seg button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 4px var(--shadow); color: var(--accent); }
.menu.fill { flex: 1; min-height: 0; }
.ai-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-wrap .chat { padding: 0; min-height: 160px; }
.ai-wrap .chat-input { margin: 0 -12px -24px; }

/* 進度 */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--mute); }
.week .dot { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; background: var(--bg-2); font-size: 15px; }
.week .dot.on { background: var(--accent); color: var(--ink); }
.week .today .dot { box-shadow: 0 0 0 2px var(--accent); }
.av-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.av-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 14px; border: 2px solid transparent; background: var(--surface-2); font-size: 11px; color: var(--mute); }
.av-cell .av-box { width: 56px; height: 56px; }
.av-cell.locked .av-box { filter: grayscale(1); opacity: .45; }
.av-cell[aria-pressed="true"] { border-color: var(--accent); }
.mbar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--bg-2); }
.mbar i { display: block; height: 100%; }
.mbar .m0 { background: var(--accent-2); }
.mbar .m1 { background: var(--teal); }
.mbar .m2 { background: var(--good); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 999px; background: currentColor; }
.legend .m0 { color: var(--accent); }
.legend .m1 { color: var(--teal); }
.legend .m2 { color: var(--good); }
.trophy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trophy { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; background: var(--surface-2); font-size: 13px; }
.trophy .t-ic { font-size: 20px; }
.trophy.off { opacity: .45; filter: grayscale(1); }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; }
.rank-row.me { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent-2); }
.rank-row .no { width: 28px; text-align: center; font-weight: 800; }
.rank-row .av-box { width: 36px; height: 36px; }
.rank-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .w { font-weight: 800; color: var(--teal); }

/* 我的 / 表單 */
.me-head { flex-direction: row; align-items: center; gap: 12px; }
.me-head .av-box { width: 64px; height: 64px; flex: none; }
.me-head .nick { font-size: 20px; font-weight: 800; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu button { display: flex; align-items: center; gap: 12px; text-align: left; }
.menu button .m-ic { width: 28px; font-size: 20px; text-align: center; }
.menu button .grow { flex: 1; }
.menu button.danger { color: var(--danger); }
.form { display: flex; flex-direction: column; gap: 8px; }
.switch { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 15px; color: var(--text); }
.switch .grow { flex: 1; min-width: 0; }
.switch small { display: block; font-size: 13px; color: var(--mute); }
.switch input[type="checkbox"] { width: 44px; min-height: 28px; height: 28px; accent-color: var(--accent); }
.switch input[type="range"] { width: 140px; min-height: 28px; accent-color: var(--accent); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--ink); }
.rescue { font-size: 28px; font-weight: 800; letter-spacing: 4px; text-align: center; padding: 12px; border-radius: 14px; background: var(--bg-2); user-select: all; }
textarea { font: inherit; font-size: 16px; min-height: 96px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--surface); }

/* 單字本 */
.wb-tools { display: flex; flex-direction: column; gap: 8px; position: sticky; top: -12px; padding: 4px 0 8px; background: var(--surface); z-index: 2; }
.wb-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.wb-filters button { flex: none; min-height: 36px; padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.wb-filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.wb-row { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.wb-row .pic { width: 40px; height: 40px; flex: none; }
.wb-row .grow { flex: 1; min-width: 0; }
.wb-row b { font-size: 15px; }
.wb-row small { display: block; font-size: 13px; color: var(--mute); }
.wb-row .m { font-size: 11px; }
.ex-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.ex-btn small { font-size: 13px; color: var(--mute); }
.wb-detail { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); }

/* 新手引導 */
#onboard { position: absolute; inset: 0; z-index: 80; display: flex; flex-direction: column; background: linear-gradient(var(--bg-2), var(--bg)); }
#onboard[hidden] { display: none; }
.ob-top { display: flex; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; }
.ob-top .bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.ob-top .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.ob-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ob-body h2 { font-size: 20px; }
.ob-body .hero { font-size: 28px; text-align: center; padding: 24px 0 8px; }
.ob-body.center { text-align: center; }
.ob-body .hero-ic { font-size: 28px; width: 96px; height: 96px; margin: 24px auto 8px; display: grid; place-items: center; border-radius: 999px; background: var(--surface); box-shadow: 0 4px 12px var(--shadow); }
.ob-opts { display: grid; gap: 8px; }
.ob-opts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ob-opts.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ob-opts button { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ob-opts button small { font-size: 11px; color: var(--mute); }
.ob-opts button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--glow); }
.ob-opts button .day { font-size: 28px; font-weight: 800; }
.ob-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.ob-foot button { min-height: 56px; font-size: 20px; }

/* 確認框 */
#dialog { position: absolute; inset: 0; z-index: 95; display: grid; place-items: center; padding: 24px; background: var(--scrim); }
#dialog[hidden] { display: none; }
.dlg-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; padding: 16px; border-radius: 14px; background: var(--surface); }
.dlg-text { font-size: 15px; white-space: pre-line; }
.dlg-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }

/* 結算(殼層的 .shell-result)補強 */
.shell-result .sr-note { white-space: pre-line; font-size: 13px; color: var(--text); }
.shell-result .sr-chip { font-size: 13px; }

/* ── 道具小圖示(art.js 的 prop / starRow / fillProps:有圖用圖、沒圖退回 emoji)──────────── */
img.prop-img { display: inline-block; object-fit: contain; vertical-align: middle; }
.has-art { background: none !important; box-shadow: none !important; }
.has-art > img { display: block; width: 100%; height: 100%; object-fit: contain; }
img.coin-ic { border-radius: 0; background: none; box-shadow: none; }
img.coin-fly { border-radius: 0; background: none; }
.pill-ic.has-art { display: inline-block; width: 18px; height: 18px; }
img.btn-ic { width: 20px; height: 20px; }
img.h-ic { width: 22px; height: 22px; margin-right: 4px; }
img.mic-ic { width: 44px; height: 44px; }
img.hero-pic { width: 60px; height: 60px; }
img.t-ic { width: 26px; height: 26px; }
img.dot-ic { width: 20px; height: 20px; }
img.pill-pic { width: 20px; height: 20px; }
img.g-ic { width: 40px; height: 40px; }
img.part-ic { width: 40px; height: 40px; }
img.meter-ic { width: 18px; height: 18px; }
img.sr-coin { width: 28px; height: 28px; margin-right: 4px; vertical-align: -4px; }
.star-row { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
img.st { width: 18px; height: 18px; }
span.st.on { color: var(--gold); }
span.st.off { color: var(--border); }
.star-row.sr img.st { width: 28px; height: 28px; }
.star-row.sr span.st { font-size: 20px; }
.star-row.plate-stars img.st { width: 14px; height: 14px; }
.claw-arm.has-art::after { display: none; }
.claw-arm img.claw-head { position: absolute; left: 50%; top: 100%; width: 44px; height: 44px; transform: translate(-50%, -4px); }

@media (prefers-reduced-motion: reduce) {
  .feedback, .coin-fly, .flash-good, .flash-bad { animation: none; }
  .faller, .walker { transition: none; }
}
