/* 英語生活小鎮：樣式。系統字體堆疊，無外部資源。 */
:root {
  --bg: #fff4dc;
  --ink: #2f4858;
  --ink-soft: #5b7283;
  --teal: #2f9e8f;
  --teal-dark: #1f776b;
  --orange: #ff9f45;
  --orange-dark: #d9772a;
  --red: #ef5b5b;
  --green: #3fb55d;
  --blue: #4d96ff;
  --yellow: #ffd24d;
  --card: #ffffff;
  --line: #e5d3ad;
  --footer-h: 44px;
  --topbar-h: 52px;
  --radius: 18px;
  --shadow: 0 4px 0 rgba(47, 72, 88, 0.18);
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
img { max-width: 100%; }
:focus-visible { outline: 4px solid #1a6dff; outline-offset: 2px; }

/* ── 版面骨架：頁尾固定在底部，#app 保留其高度 ───────────────── */
#app { position: fixed; inset: 0 0 var(--footer-h) 0; display: flex; flex-direction: column; }
#screens { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }

#site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  background: #1f3d4a; color: #f4f1e8; font-size: 12px; line-height: 1.45; text-align: center;
}
#site-footer a { color: #ffe08a; text-underline-offset: 2px; }
#site-footer a:focus-visible { outline-color: #fff; }

.topbar {
  display: flex; align-items: center; gap: 8px; min-height: var(--topbar-h);
  padding: max(6px, env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 6px calc(10px + env(safe-area-inset-left, 0px));
  background: var(--teal); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12); z-index: 20;
}
.brand { flex: 1; font-weight: 800; font-size: 18px; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tools { display: flex; gap: 6px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-width: 44px;
  border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.22); color: #fff; font-size: 22px; font-weight: 800;
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.34); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.small { width: 40px; height: 40px; min-width: 40px; background: rgba(47, 72, 88, 0.12); color: var(--ink); }
.icon-btn svg { display: block; }

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 8px 20px;
  border: 3px solid var(--line); border-bottom-width: 6px; border-radius: 16px; background: #fff; color: var(--ink);
  font-weight: 800; font-size: 18px; transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); border-bottom-width: 3px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--orange); border-color: var(--orange-dark); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.btn.danger { background: #fff0f0; border-color: var(--red); color: #b52b2b; }
.btn.huge { font-size: clamp(22px, 6vw, 30px); padding: 12px 36px; min-height: 64px; border-radius: 22px; }
.btn.replay { font-size: 16px; min-height: 44px; padding: 4px 16px; }
.btn.next { min-height: 44px; font-size: 16px; padding: 4px 16px; }

/* ── 主選單 ──────────────────────────────────────────────────── */
#screen-menu {
  background: linear-gradient(rgba(255, 244, 220, 0.35), rgba(255, 244, 220, 0.75)), url(../assets/img/bg-title.webp) center / cover no-repeat, #bfe6f5;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.menu-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 520px; width: 100%; padding: 18px 20px 22px; text-align: center;
  background: rgba(255, 255, 255, 0.82); border-radius: 28px; box-shadow: 0 8px 0 rgba(47, 72, 88, 0.15);
}
.menu-mascot { width: clamp(110px, 28vh, 200px); height: auto; animation: float 3s ease-in-out infinite; }
.game-title { margin: 0; font-size: clamp(34px, 9vw, 52px); line-height: 1.15; color: var(--teal-dark); letter-spacing: 3px; text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(47, 72, 88, 0.15); }
.game-sub { margin: 0 0 8px; color: var(--ink-soft); font-weight: 700; }
.menu-town { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; }

/* ── 選關 ────────────────────────────────────────────────────── */
#screen-levels { padding: 10px 12px 20px; background: linear-gradient(#cfeefb, #fff4dc 240px); }
.town-banner { max-width: 980px; margin: 0 auto 12px; padding: 10px 12px; background: rgba(255, 255, 255, 0.8); border-radius: 22px; box-shadow: var(--shadow); }
.town-row { display: flex; gap: 8px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.town-row > .bld { flex: 1 1 70px; min-width: 64px; }
.bld { display: flex; flex-direction: column; align-items: center; text-align: center; filter: grayscale(1) brightness(0.9); opacity: 0.55; transition: filter 0.4s, opacity 0.4s; }
.bld.lit { filter: none; opacity: 1; }
.bld img { width: clamp(52px, 12vw, 96px); height: auto; }
.bld.full img { animation: bounce 1.6s ease-in-out infinite; filter: drop-shadow(0 0 8px #ffd24d); }
.bld-name { font-size: 12px; font-weight: 800; }
.bld-prog { font-size: 12px; color: var(--ink-soft); }
.decor-col { display: flex; gap: 4px; align-items: flex-end; }
.decor { opacity: 0.3; filter: grayscale(1); }
.decor.on { opacity: 1; filter: none; animation: bounce 2.2s ease-in-out infinite; }
.decor img { width: clamp(34px, 8vw, 56px); height: auto; }
.crowd { display: flex; flex-wrap: wrap; gap: 2px; min-height: 28px; margin: 4px 0; font-size: 24px; }
.person { display: inline-block; animation: hop 1.4s ease-in-out infinite; }
.town-stats { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-weight: 700; font-size: 14px; }
.buzz { flex: 1 1 100px; height: 12px; border-radius: 8px; background: #e8dcc0; overflow: hidden; }
.buzz i { display: block; height: 100%; background: linear-gradient(90deg, #ffd24d, #ff9f45); border-radius: 8px; transition: width 0.6s; }

.district-list { max-width: 980px; margin: 0 auto; display: grid; gap: 14px; }
.district { background: #fff; border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.district-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background-size: cover; background-position: center; }
.district-head h2 { margin: 0; font-size: 18px; }
.district-head p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.district-count { font-weight: 800; background: var(--yellow); border-radius: 12px; padding: 2px 10px; white-space: nowrap; }
.level-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; min-height: 128px; padding: 8px 4px 8px;
  border: 3px solid var(--line); border-bottom-width: 6px; border-radius: 16px; background: #fffaf0; text-align: center; transition: transform 0.1s;
}
.level-card:hover { transform: translateY(-2px); }
.level-card:active { transform: translateY(2px); }
.level-card.passed { background: #eaf9ee; border-color: #8fd3a0; }
.level-card.locked { background: #eceff1; border-color: #cfd8dc; color: #78909c; }
.lv-no { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800; }
.locked .lv-no { background: #90a4ae; }
.lv-title { font-weight: 800; font-size: 14px; line-height: 1.25; min-height: 2.5em; display: flex; align-items: center; }
.lv-mech { font-size: 11px; background: #ffe9c7; border-radius: 8px; padding: 0 8px; }
.lv-stars { color: #f5a623; letter-spacing: 1px; font-size: 16px; }
.lv-best { font-size: 11px; color: var(--ink-soft); }

/* ── 遊戲畫面 ────────────────────────────────────────────────── */
#screen-play { display: flex; flex-direction: column; overflow: hidden; background-size: cover; background-position: center; background-color: #dff3fb; }
#screen-play::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.5); pointer-events: none; }
#screen-play > * { position: relative; }
#screen-play[data-bg="plaza"] { background-image: url(../assets/img/bg-plaza.webp); }
#screen-play[data-bg="bakery"] { background-image: url(../assets/img/bg-bakery.webp); }
#screen-play[data-bg="sports"] { background-image: url(../assets/img/bg-sports.webp); }
#screen-play[data-bg="home"] { background-image: url(../assets/img/bg-home.webp); }

.hud { display: flex; align-items: center; gap: 8px; padding: 6px 10px; flex-wrap: wrap; background: rgba(255, 255, 255, 0.85); }
.hud-level { font-weight: 800; flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-stats { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hud-chip { padding: 2px 10px; border-radius: 12px; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: 14px; white-space: nowrap; }
.hud-chip.score { background: #fff4c7; border-color: #f2d36b; }
.hud-chip.combo { background: #ffe0d6; border-color: #ff9f7a; animation: pulse 0.6s; }
.timer { height: 12px; background: rgba(47, 72, 88, 0.18); overflow: hidden; }
.timer-bar { height: 100%; width: 100%; transform-origin: left center; background: linear-gradient(90deg, #4cc9a0, #ffd24d); will-change: transform; }
.timer.danger .timer-bar { background: var(--red); animation: blink 0.5s infinite; }

.stage { flex: 1; min-height: 0; padding: 8px 10px; overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; }
.stage > * { flex: 1 0 auto; }
.coach { display: flex; align-items: center; gap: 8px; padding: 4px 10px 6px; background: rgba(255, 255, 255, 0.85); min-height: 58px; }
.coach-mascot { width: 52px; height: 52px; object-fit: contain; flex: none; }
.coach-bubble { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 16px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: 15px; line-height: 1.3; }
.coach-bubble.pop { animation: pop 0.35s; }

/* 題目：提示區 + 選項 */
.choice { display: flex; flex-direction: column; gap: 10px; justify-content: center; max-width: 760px; width: 100%; margin: 0 auto; }
.q-prompt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 12px; background: rgba(255, 255, 255, 0.94); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.q-zh { font-weight: 800; font-size: clamp(17px, 4.4vw, 22px); }
.q-en { font-weight: 800; font-size: clamp(20px, 5.4vw, 28px); color: var(--teal-dark); }
.v-caption { font-weight: 800; font-size: clamp(18px, 5vw, 26px); color: var(--teal-dark); }
.visual { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.v-icon .emoji, .opt-icon .emoji { font-size: clamp(56px, 16vw, 96px); line-height: 1.1; }
.v-icon svg { width: clamp(70px, 22vw, 100px); height: auto; }
.clock-svg { width: min(170px, 30vh, 60vw); height: auto; }
.scene-svg { width: min(260px, 70vw, 40vh); height: auto; border-radius: 14px; border: 3px solid #cfe5f5; }
.speaker-btn {
  position: relative; display: grid; place-items: center; width: 84px; height: 84px; border: 0; border-radius: 50%; background: var(--blue); color: #fff; font-size: 32px;
  box-shadow: 0 5px 0 #2c6dc9; transition: transform 0.1s;
}
.speaker-btn svg { width: 40px; height: 40px; }
.speaker-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #2c6dc9; }
.speaker-btn.small { width: 48px; height: 48px; font-size: 22px; flex: none; }
.speaker-btn .rings { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(77, 150, 255, 0.5); animation: ring 1.8s infinite; }
.v-card { position: relative; width: min(220px, 60vw); padding: 10px; border-radius: 20px; border: 4px solid; background: #fff; }
.v-card.yes { border-color: #6cc788; background: #effaf2; }
.v-card.no { border-color: #ee8f8f; background: #fff1f1; }
.card-face { font-size: 34px; }
.card-obj { font-size: clamp(54px, 15vw, 80px); line-height: 1.1; }
.card-badge { font-weight: 800; font-size: 18px; padding: 2px 14px; border-radius: 12px; background: #fff; }
.v-card.yes .card-badge { color: #207a3b; }
.v-card.no .card-badge { color: #b52b2b; }
.v-owners { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
.owner-card { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 4px; padding: 6px 12px; border-radius: 16px; background: #f4f9ff; border: 3px solid #bcd8f5; }
.owner-kid { font-size: 36px; grid-row: span 2; }
.owner-name { font-weight: 800; }
.owner-item { font-size: 34px; grid-column: 2; }
.owner-card { grid-template-columns: auto auto; }
.v-calendar .cal-row { display: flex; gap: 4px; }
.cal-day { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #eef3f7; font-weight: 800; }
.cal-day.on { background: var(--orange); color: #fff; transform: scale(1.15); }
.v-dialog { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; text-align: left; }
.line-btn { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 6px 10px; border: 2px solid #d6e6f5; border-radius: 14px; background: #f7fbff; text-align: left; font-size: clamp(15px, 4vw, 18px); }
.line-btn:hover { background: #e9f4ff; }
.line-btn .who { flex: none; font-weight: 800; color: var(--blue); min-width: 3.6em; }

.options { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.options.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.options.n3.long { grid-template-columns: minmax(0, 1fr); }
.options.mode-clock { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.options.mode-clock.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.opt {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 8px 10px; border: 4px solid var(--line); border-bottom-width: 7px;
  border-radius: var(--radius); background: #fff; font-weight: 800; font-size: clamp(18px, 4.6vw, 26px); transition: transform 0.1s, background 0.15s;
}
.opt:hover:not(:disabled) { background: #fff8e6; transform: translateY(-2px); }
.opt:active:not(:disabled) { transform: translateY(3px); }
.opt kbd { position: absolute; left: 6px; top: 4px; font: 700 12px/1 inherit; color: var(--ink-soft); }
.opt-clock .clock-svg { width: min(100px, 22vw, 15vh); }
.opt-scene .scene-svg { width: min(160px, 38vw, 22vh); }
.opt-icon .emoji { font-size: clamp(40px, 11vw, 60px); line-height: 1.1; }
.opt-icon svg { width: clamp(46px, 12vw, 64px); height: auto; }
.opt.correct, .bubble.correct, .mole.correct { background: #d8f5df; border-color: var(--green); animation: pop 0.45s; }
.opt.wrong, .bubble.wrong, .mole.wrong { background: #ffe0e0; border-color: var(--red); animation: shake 0.5s; }
.opt.dim, .bubble.dim, .mole.dim { opacity: 0.45; }
.opt.correct::after, .bubble.correct::after, .mole.correct::after { content: "✔"; position: absolute; right: 8px; top: 2px; color: var(--green); font-size: 22px; }
.opt.wrong::after, .bubble.wrong::after, .mole.wrong::after { content: "✘"; position: absolute; right: 8px; top: 2px; color: var(--red); font-size: 22px; }

/* 下落接字 */
.falling, .whack { display: flex; flex-direction: column; gap: 6px; max-width: 760px; width: 100%; margin: 0 auto; min-height: 0; }
.fall-hint { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(255, 255, 255, 0.92); border-radius: var(--radius); }
.fall-field { position: relative; flex: 1; min-height: 240px; overflow: hidden; border-radius: var(--radius); background: linear-gradient(rgba(255, 255, 255, 0.4), rgba(173, 223, 245, 0.55)); border: 3px solid rgba(255, 255, 255, 0.8); }
.bubble {
  position: absolute; top: 0; left: 50%; display: flex; align-items: center; justify-content: center; width: clamp(70px, 19vw, 104px); aspect-ratio: 1; padding: 4px; border-radius: 50%;
  border: 4px solid #8cc8f2; background: radial-gradient(circle at 30% 30%, #fff, #d9f0ff 70%); font-weight: 800; font-size: clamp(18px, 4.6vw, 26px); will-change: transform;
}
.bubble .opt-text { font-size: clamp(15px, 3.8vw, 22px); text-align: center; line-height: 1.1; }
.bubble .opt-icon .emoji { font-size: clamp(34px, 9vw, 52px); }
.bubble.popped { animation: popout 0.3s forwards; }

/* 打地鼠 */
.whack-grid { display: grid; gap: 10px 8px; padding: 10px 4px; flex: 1; align-content: center; }
.whack-grid.holes-6 { grid-template-columns: repeat(3, 1fr); }
.whack-grid.holes-4 { grid-template-columns: repeat(2, 1fr); }
.hole { position: relative; height: clamp(110px, 22vh, 170px); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.mound { position: absolute; bottom: 0; left: 4%; right: 4%; height: 28%; border-radius: 50% 50% 18px 18px / 70% 70% 18px 18px; background: #8a5a2b; box-shadow: inset 0 8px 0 #6f451d; z-index: 2; }
.mole {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; margin-bottom: 4%; padding: 0; border: 0; background: transparent; animation: moleUp 0.35s ease-out both;
}
.mole-face { font-size: clamp(44px, 10vw, 64px); line-height: 1; }
.sign { margin-bottom: -4px; min-width: 56px; padding: 2px 10px; border-radius: 12px; background: #fff; border: 3px solid #c9a96b; font-weight: 800; }
.sign .emoji { font-size: clamp(30px, 7vw, 44px); }
.mole.correct .sign { background: #d8f5df; }
.hole .hammer { position: absolute; top: 4%; right: 18%; font-size: 44px; z-index: 3; animation: hammer 0.35s ease-out both; }
.hole.hit .mole { animation: none; transform: translateY(18%) scale(0.92); }

/* 句子排序 / 拼字 */
.sort, .spell, .match, .memory { display: flex; flex-direction: column; gap: 12px; max-width: 760px; width: 100%; margin: 0 auto; justify-content: center; }
.sort-slots, .spell-slots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 64px; padding: 10px; background: rgba(255, 255, 255, 0.9); border-radius: var(--radius); border: 3px dashed var(--line); }
.sort-slots.ok, .spell-slots.ok { border-color: var(--green); background: #effaf2; border-style: solid; }
.sort-slots.bad, .spell-slots.bad { border-color: var(--red); background: #fff1f1; border-style: solid; animation: shake 0.5s; }
.sort-pool, .spell-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 56px; }
.tile {
  min-width: 48px; min-height: 48px; padding: 6px 14px; border: 3px solid #b9d4ee; border-bottom-width: 6px; border-radius: 14px; background: #eef6ff; font-weight: 800; font-size: clamp(18px, 4.8vw, 24px);
  transition: transform 0.1s;
}
.tile:active:not(:disabled) { transform: translateY(2px); }
.tile.placed { background: #fff8e6; border-color: #f0cf8b; }
.tile.locked { background: #e9f9ee; border-color: #8fd3a0; }
.tile.letter { text-transform: lowercase; min-width: 52px; font-size: clamp(22px, 6vw, 30px); }
.slot { display: inline-block; min-width: 48px; height: 48px; border-bottom: 5px solid var(--line); }
.sort-actions { display: flex; justify-content: center; }
.sort-answer { text-align: center; font-weight: 800; font-size: clamp(18px, 4.8vw, 24px); color: var(--teal-dark); }
.sort .q-prompt { flex-direction: row; justify-content: center; }

/* 配對 / 翻牌 */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.match .q-zh, .memory .q-zh { text-align: center; padding: 6px 10px; background: rgba(255, 255, 255, 0.92); border-radius: var(--radius); }
.card.match-card { min-height: 52px; border: 3px solid var(--line); border-bottom-width: 6px; border-radius: 14px; background: #fff; font-weight: 800; font-size: clamp(16px, 4.4vw, 22px); transition: transform 0.1s; }
.match-card.selected { background: #fff2cc; border-color: var(--orange); transform: scale(1.04); }
.match-card.done { background: #d8f5df; border-color: var(--green); opacity: 0.7; }
.match-card.wrong { background: #ffe0e0; border-color: var(--red); animation: shake 0.5s; }
.memory-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mem-card { position: relative; aspect-ratio: 4 / 5; padding: 0; border: 0; background: transparent; perspective: 600px; }
.mem-inner { position: absolute; inset: 0; transition: transform 0.35s; transform-style: preserve-3d; }
.mem-card.open .mem-inner, .mem-card.done .mem-inner { transform: rotateY(180deg); }
.mem-back, .mem-front { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 3px solid; }
.mem-back { background: var(--teal); border-color: var(--teal-dark); color: #fff; font-size: 30px; }
.mem-front { background: #fff; border-color: var(--line); transform: rotateY(180deg); padding: 2px; }
.mem-text { font-weight: 800; font-size: clamp(13px, 3.6vw, 20px); text-align: center; line-height: 1.1; }
.mem-icon .emoji { font-size: clamp(30px, 8vw, 46px); }
.mem-icon svg { width: clamp(34px, 9vw, 48px); height: auto; }
.mem-card.done .mem-front { background: #d8f5df; border-color: var(--green); }
.mem-card.wrong .mem-front { background: #ffe0e0; border-color: var(--red); }

/* ── 對話框 ──────────────────────────────────────────────────── */
.modal-backdrop { position: absolute; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(31, 61, 74, 0.55); overflow: auto; animation: fade 0.2s; }
.modal { width: min(480px, 100%); max-height: 100%; overflow: auto; margin: auto; padding: 18px 18px 16px; background: #fffdf7; border-radius: 24px; border: 4px solid var(--line); box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18); text-align: center; animation: pop 0.3s; }
.modal-title { margin: 0 0 8px; font-size: 24px; color: var(--teal-dark); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.intro-mascot, .result-mascot { width: 110px; height: 110px; object-fit: contain; }
.intro-no { font-weight: 800; color: var(--orange-dark); }
.intro-sec { margin: 0; color: var(--ink-soft); font-weight: 700; }
.intro-goal { font-size: 18px; font-weight: 700; margin: 8px 0; }
.intro-meta { margin: 0; font-size: 14px; color: var(--ink-soft); }
.result-stars { display: flex; justify-content: center; gap: 8px; font-size: 52px; line-height: 1; margin: 4px 0; }
.rstar { color: #d9d3c4; transform: scale(0.6); transition: transform 0.3s, color 0.3s; }
.rstar.on { color: #ffb400; transform: scale(1.15); text-shadow: 0 3px 0 #c98600; }
.rstar.off { transform: scale(0.9); }
.result p { margin: 4px 0; }
.result-score { font-size: 22px; }
.result-score strong { font-size: 40px; color: var(--orange-dark); }
.result-detail { font-size: 14px; color: var(--ink-soft); }
.result-new { font-weight: 800; color: var(--orange-dark); font-size: 20px; }
.result-town { font-weight: 800; color: var(--teal-dark); }
.set-row { display: grid; grid-template-columns: 8.5em 1fr 3em; align-items: center; gap: 8px; padding: 8px 0; text-align: left; font-weight: 700; }
.set-row.check { grid-template-columns: auto 1fr; cursor: pointer; }
.set-row input[type="range"] { width: 100%; height: 32px; accent-color: var(--teal); }
.set-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--teal); }
.reset-box { margin-top: 10px; padding-top: 10px; border-top: 2px dashed var(--line); }
.reset-box .warn { color: #b52b2b; font-weight: 800; }
.reset-box .row { display: flex; gap: 10px; justify-content: center; }
.help-steps { text-align: left; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.help-steps li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.step-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; background: #e9f4ff; font-size: 22px; }

/* ── 特效層 ──────────────────────────────────────────────────── */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1500; overflow: hidden; }
.confetti { position: fixed; width: 10px; height: 14px; border-radius: 2px; }
.float-text { position: fixed; transform: translate(-50%, 0); font-weight: 900; font-size: 30px; text-shadow: 0 2px 0 #fff, 0 0 8px #fff; white-space: nowrap; }
.float-text.good { color: #1f9d45; }
.float-text.bad { color: #d23f3f; }
.flash { position: fixed; inset: 0; animation: flash 0.5s forwards; }
.flash-ok { box-shadow: inset 0 0 0 10px rgba(63, 181, 93, 0.6), inset 0 0 90px rgba(63, 181, 93, 0.35); }
.flash-bad { box-shadow: inset 0 0 0 10px rgba(239, 91, 91, 0.6), inset 0 0 90px rgba(239, 91, 91, 0.35); }
.cheat-banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); max-width: 92vw; padding: 12px 22px; border-radius: 20px; background: #ffd24d; border: 4px solid #d9a400; color: #5b3b00; font-weight: 900; font-size: clamp(20px, 5vw, 30px); text-align: center; text-wrap: balance; animation: pop 0.5s; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2); }
.toast { position: fixed; left: 50%; bottom: calc(var(--footer-h) + 14px); transform: translate(-50%, 20px); max-width: 90vw; padding: 10px 18px; border-radius: 16px; background: #2f4858; color: #fff; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 1600; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.shake { animation: shake 0.5s; }
.bump { animation: bump 0.4s; }

/* ── 動畫 ────────────────────────────────────────────────────── */
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes bounce { 50% { transform: translateY(-6px); } }
@keyframes hop { 50% { transform: translateY(-5px); } }
@keyframes pop { 0% { transform: scale(0.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes bump { 50% { transform: scale(1.3); } }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes blink { 50% { opacity: 0.45; } }
@keyframes ring { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes popout { to { transform: translate(-50%, 0) scale(1.5); opacity: 0; } }
@keyframes moleUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes hammer { 0% { transform: rotate(-60deg) translateY(-20px); opacity: 0; } 50% { opacity: 1; } 100% { transform: rotate(10deg); opacity: 0.9; } }

/* 動畫減弱：縮短/取消位移動畫，仍保留顏色、圖示與文字回饋 */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
.reduce-motion .menu-mascot, .reduce-motion .person, .reduce-motion .decor.on, .reduce-motion .bld.full img { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── 響應式 ──────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand { font-size: 16px; }
  .set-row { grid-template-columns: 7em 1fr 3em; }
  .modal-actions .btn { flex: 1 1 130px; }
}
@media (min-width: 521px) and (max-width: 760px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 高度較矮的螢幕（桌機 720p、小手機）：縮小提示區圖像，讓題目與選項不必捲動 */
@media (max-height: 760px) {
  .v-card { padding: 4px 10px; }
  .card-face { font-size: 26px; line-height: 1.1; }
  .card-obj { font-size: 56px; }
  .clock-svg { width: min(140px, 22vh); }
  .memory-grid { width: min(100%, 64vh); margin-inline: auto; }
  .v-owners { flex-wrap: nowrap; gap: 6px; }
  .owner-card { padding: 4px 8px; border-width: 2px; }
  .owner-kid, .owner-item { font-size: 28px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  :root { --topbar-h: 44px; }
  .topbar { min-height: 44px; padding-top: 3px; padding-bottom: 3px; }
  .icon-btn { width: 38px; height: 38px; min-width: 38px; }
  .hud { padding: 3px 10px; }
  .coach { min-height: 44px; padding: 2px 10px; }
  .coach-mascot { width: 38px; height: 38px; }
  .coach-bubble { font-size: 13px; padding: 2px 10px; }
  .stage { padding: 4px 10px; }
  .choice { flex-direction: row; align-items: center; max-width: none; gap: 12px; }
  .choice > .q-prompt { flex: 1 1 45%; padding: 6px; gap: 2px; }
  .choice > .options { flex: 1 1 55%; gap: 8px; }
  .choice .opt { min-height: 54px; }
  .options.mode-clock { grid-template-columns: repeat(3, 1fr); }
  .options.mode-clock.n4 { grid-template-columns: repeat(4, 1fr); }
  .v-dialog { gap: 3px; }
  .line-btn { padding: 2px 8px; font-size: 14px; line-height: 1.3; }
  .clock-svg { width: min(120px, 34vh); }
  .speaker-btn { width: 60px; height: 60px; }
  .v-icon .emoji { font-size: 56px; }
  .card-obj { font-size: 42px; }
  .card-face { font-size: 22px; line-height: 1.1; }
  .card-badge { font-size: 15px; }
  .v-card { padding: 2px 10px; }
  .choice .q-prompt { position: relative; }
  .choice .q-zh { font-size: 15px; }
  .choice .q-en, .choice .v-caption { font-size: 18px; }
  .choice .btn.replay { position: absolute; right: 6px; top: 6px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 0; border-radius: 50%; }
  .choice .btn.replay::before { content: "🔊"; font-size: 20px; }
  .choice .opt { font-size: 16px; padding: 4px 6px; }
  .scene-svg { width: min(150px, 34vh); }
  .fall-field { min-height: 130px; }
  .hole { height: 22vh; }
  .menu-card { flex-direction: row; flex-wrap: wrap; max-width: 760px; justify-content: center; gap: 4px 20px; }
  .menu-mascot { width: 110px; }
  .modal { padding: 10px 14px; }
  .intro-mascot, .result-mascot { width: 60px; height: 60px; }
  .result-stars { font-size: 36px; }
  .memory-grid { grid-template-columns: repeat(6, 1fr); }
  .mem-card { aspect-ratio: 1; }
  .level-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .level-card { min-height: 96px; }
  .town-banner { padding: 6px 10px; }
  .sort-slots, .spell-slots { min-height: 52px; padding: 6px; }

  /* 手機橫向（可用高度約 200px）：非選擇題玩法也要一眼看完、不必捲動 */
  .match, .memory, .sort, .spell { gap: 6px; }
  .match .q-zh, .memory .q-zh { font-size: 15px; padding: 2px 10px; }
  .match-cols { gap: 10px; }
  .match-col { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .card.match-card { min-height: 46px; font-size: 16px; padding: 2px 4px; }
  .mem-card { aspect-ratio: auto; height: clamp(56px, 20vh, 110px); }
  .mem-icon .emoji { font-size: 34px; }
  .whack-grid { padding: 0 4px; gap: 6px; }
  .whack-grid.holes-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .whack-grid.holes-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hole { height: clamp(110px, 34vh, 150px); }
  .mole-face { font-size: 40px; }
  .fall-hint { padding: 2px 10px; }
  .sort, .spell { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); grid-auto-rows: min-content; align-content: center; column-gap: 12px; max-width: none; }
  .sort > .q-prompt, .spell > .q-prompt { grid-column: 1; grid-row: 1 / span 4; align-self: center; padding: 6px; gap: 4px; }
  .sort > :not(.q-prompt), .spell > :not(.q-prompt) { grid-column: 2; }
  .sort .q-prompt { flex-direction: column; }
  .sort .q-zh, .spell .q-zh { font-size: 15px; }
  .sort .speaker-btn { width: 52px; height: 52px; font-size: 24px; }
  .spell .v-icon svg { width: 64px; }
  .spell .v-icon .emoji { font-size: 48px; }
  .spell .v-caption { font-size: 18px; }
  .tile { min-height: 44px; padding: 2px 10px; font-size: 18px; }
  .tile.letter { min-width: 44px; font-size: 22px; }
  .slot { min-width: 40px; height: 40px; }
  .sort-pool, .spell-pool { min-height: 44px; gap: 6px; }
  .sort-answer { font-size: 17px; }
  .memory-grid { width: 100%; }
}
@media (max-height: 700px) and (orientation: portrait) {
  .menu-mascot { width: 100px; }
  .q-prompt { padding: 6px 10px; gap: 2px; }
  .card-face { font-size: 20px; }
  .card-obj { font-size: 40px; }
  .card-badge { font-size: 15px; }
  .v-icon .emoji { font-size: 56px; }
  .options { gap: 8px; }
  .opt { min-height: 54px; }
  .mem-card { aspect-ratio: 1; }
  .hole { height: clamp(96px, 18vh, 140px); }
  .owner-name { font-size: 14px; }
  .spell .v-icon svg { width: 56px; }
  .spell .v-icon .emoji { font-size: 48px; }
  .sort-slots, .spell-slots { min-height: 52px; padding: 6px; }
  .tile { min-height: 44px; padding: 2px 10px; }
  .tile.letter { min-width: 42px; padding: 2px 6px; }
  .slot { min-width: 38px; height: 40px; }
  .sort-pool, .spell-pool { gap: 6px; }
  .speaker-btn { width: 64px; height: 64px; }
  .clock-svg { width: min(130px, 22vh); }
  .scene-svg { width: min(200px, 26vh); }
}
