/* 時光旅行日記：樣式。純 CSS，無外部字型。 */

:root {
  --paper: #fff8e8;
  --paper-2: #fdeccc;
  --ink: #4a3426;
  --ink-soft: #7a6354;
  --teal: #1f9d8f;
  --coral: #e86a4f;
  --gold: #f2a93b;
  --sky: #3aa6dc;
  --purple: #7a5cc9;
  --good: #2e9e5b;
  --bad: #d9482b;
  --accent: var(--teal);
  --footer-h: 40px;
  --top-h: 52px;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(74, 52, 38, 0.18);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-en: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, "PingFang TC", sans-serif;
  --font-title: "Kaiti TC", "BiauKai", "DFKai-SB", "Noto Serif TC", "PingFang TC", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: #2b2142;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
[lang="en"] { font-family: var(--font-en); }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #1b6dff; outline-offset: 2px; }

/* 背景 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: #fdf3dc center / cover no-repeat;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(rgba(255, 248, 232, 0.55), rgba(255, 244, 220, 0.78));
}
body[data-bg="menu"]::before { background-image: url("../assets/img/bg_menu.webp"); }
body[data-bg="s1"]::before { background-image: url("../assets/img/bg_s1.webp"); }
body[data-bg="s2"]::before { background-image: url("../assets/img/bg_s2.webp"); }
body[data-bg="s3"]::before { background-image: url("../assets/img/bg_s3.webp"); }
body[data-bg="s4"]::before { background-image: url("../assets/img/bg_s4.webp"); }

/* 版面骨架 */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.topbar {
  flex: none; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 8px;
  background: rgba(43, 33, 66, 0.86); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; font-weight: 700; font-size: 1.05rem; min-height: 44px; padding: 0 6px; border-radius: 12px; font-family: var(--font-title); }
.brand img { border-radius: 8px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 1.3rem; line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.icon-btn[hidden] { display: none; }
.game .icon-btn, .modal .icon-btn { background: rgba(74, 52, 38, 0.12); color: var(--ink); }

.screen { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 10px 12px 14px; -webkit-overflow-scrolling: touch; }
.screen[data-screen="game"] { overflow: hidden; padding: 6px 8px 6px; }

.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  background: #2b2142; color: #efe6ff; text-align: center; font-size: 0.78rem; line-height: 1.35;
}
.site-footer a { color: #ffd166; }
.noscript { padding: 16px; background: #fff; }

/* 按鈕 */
.btn {
  min-height: 48px; padding: 8px 20px; border-radius: 14px; border: 2px solid var(--ink);
  background: #fff; color: var(--ink); font-weight: 700; font-size: 1.05rem; box-shadow: 0 3px 0 rgba(74, 52, 38, 0.35);
  transition: transform 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(74, 52, 38, 0.35); }
.btn.primary { background: var(--accent); border-color: #14665d; color: #fff; }
.btn.danger { background: var(--bad); border-color: #8e2a14; color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { min-height: 60px; padding: 10px 36px; font-size: 1.35rem; border-radius: 18px; }
.btn.small { min-height: 44px; padding: 4px 14px; font-size: 0.95rem; }

/* 主選單 */
.menu { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 8px 0; }
.menu-mascot { width: min(44vw, 220px); height: auto; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.25)); animation: bob 2.6s ease-in-out infinite; }
.title { margin: 4px 0 0; font-family: var(--font-title); font-size: clamp(2.2rem, 9vw, 3.4rem); letter-spacing: 0.08em; color: #fff; text-shadow: 0 3px 0 #5a3fa0, 0 6px 14px rgba(0, 0, 0, 0.35); }
.subtitle { margin: 0; font-weight: 700; letter-spacing: 0.14em; color: #ffe29a; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); }
.tagline { margin: 6px 0 12px; max-width: 28em; padding: 8px 14px; background: rgba(255, 248, 232, 0.9); border-radius: 14px; font-size: 1rem; }
.menu-stats { margin: 8px 0 0; padding: 2px 14px; border-radius: 999px; background: rgba(43, 33, 66, 0.75); color: #ffe29a; font-weight: 700; }
.menu-tip { margin: 0; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); font-size: 0.95rem; }

/* 選關 */
.select { max-width: 880px; margin: 0 auto; display: grid; gap: 14px; }
.select-head { text-align: center; background: rgba(255, 248, 232, 0.92); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); }
.select-head h2 { margin: 0; font-family: var(--font-title); font-size: 1.6rem; }
.select-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.92rem; }
.section-card { background: rgba(255, 248, 232, 0.94); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); border-top: 8px solid var(--c, var(--teal)); }
.section-card[data-section="1"] { --c: #3aa6dc; }
.section-card[data-section="2"] { --c: #4fb56a; }
.section-card[data-section="3"] { --c: #e59a3a; }
.section-card[data-section="4"] { --c: #e0698f; }
.section-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.section-banner b { font-family: var(--font-title); font-size: 1.25rem; }
.section-banner span { color: var(--ink-soft); font-size: 0.9rem; }
.lv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lv-btn {
  position: relative; display: grid; grid-template-columns: 56px 1fr; grid-template-areas: "img title" "img meta" "img stars"; align-items: center; column-gap: 8px;
  min-height: 84px; padding: 8px 10px 8px 8px; text-align: left; border: 2px solid var(--ink); border-radius: 16px; background: #fff;
  box-shadow: 0 3px 0 rgba(74, 52, 38, 0.3); overflow: hidden;
}
.lv-btn .lv-img { grid-area: img; width: 56px; height: 56px; object-fit: contain; }
.scene-emoji { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.lv-btn .scene-emoji { font-size: 2.4rem; }
.intro .scene-emoji { font-size: 5rem; }
.lv-no { position: absolute; top: 4px; left: 6px; z-index: 1; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--ink); color: #fff; font-weight: 700; font-size: 0.8rem; text-align: center; line-height: 22px; }
.lv-title { grid-area: title; font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.lv-meta { grid-area: meta; font-size: 0.78rem; color: var(--ink-soft); }
.lv-stars { grid-area: stars; color: #e8a400; letter-spacing: 2px; font-size: 1rem; }
.lv-best { position: absolute; right: 8px; bottom: 6px; font-size: 0.72rem; color: var(--ink-soft); }
.lv-lock { grid-area: stars; }
.lv-btn.locked { background: #e9e1d2; color: #8a7a6c; border-style: dashed; }
.lv-btn.locked .lv-img { filter: grayscale(1); opacity: 0.5; }
.lv-btn.cleared { border-color: var(--good); }
.lv-btn:hover:not(.locked) { transform: translateY(-2px); }

/* 遊戲外框 */
.game { display: flex; flex-direction: column; height: 100%; min-height: 0; max-width: 980px; margin: 0 auto; gap: 6px; }
.game[data-section="1"] { --accent: #2b8fc4; }
.game[data-section="2"] { --accent: #3a9d56; }
.game[data-section="3"] { --accent: #d4821f; }
.game[data-section="4"] { --accent: #cf4f7c; }
.hud { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(255, 248, 232, 0.95); border-radius: 16px; box-shadow: var(--shadow); }
.hud-mascot { width: 48px; height: 48px; flex: none; }
.hud-mascot img { width: 48px; height: 48px; object-fit: contain; }
.hud-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.hud-title b { color: var(--accent); font-size: 0.85rem; }
.hud-title span { font-weight: 700; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-stats { display: flex; align-items: center; gap: 10px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.stat small { font-size: 0.65rem; color: var(--ink-soft); }
.hud-score { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-combo { padding: 2px 8px; border-radius: 999px; background: #ff8a3d; color: #fff; font-weight: 800; font-size: 0.8rem; white-space: nowrap; }
.hud-lives { color: #e5384f; letter-spacing: 1px; font-size: 1rem; white-space: nowrap; }
.hud-progress { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.timer { flex: none; height: 12px; border-radius: 6px; background: rgba(74, 52, 38, 0.18); overflow: hidden; }
.timer i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #2fb67c, #8ad34f); transform-origin: left center; }
.timer.low i { background: linear-gradient(90deg, #e5384f, #ff7a3d); animation: blink 0.5s steps(2) infinite; }
.timer.idle { opacity: 0.35; }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overflow-x: hidden; padding: 2px 2px 4px; }
.feedback { flex: none; min-height: 52px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; padding: 6px 12px; border-radius: 14px; text-align: center; font-weight: 700; background: rgba(255, 248, 232, 0.6); }
.feedback small { flex-basis: 100%; font-weight: 500; color: var(--ink-soft); font-size: 0.85rem; }
.feedback.ok { background: #d9f5e3; color: #17683b; }
.feedback.bad { background: #ffe1d9; color: #8f2a14; }

/* 開場 */
.intro { margin: auto; max-width: 440px; text-align: center; background: rgba(255, 248, 232, 0.96); border-radius: 22px; padding: 16px 20px 20px; box-shadow: var(--shadow); }
.intro-scene { width: 120px; height: 120px; object-fit: contain; }
.intro h2 { margin: 4px 0; font-family: var(--font-title); font-size: 1.5rem; }
.intro-blurb { margin: 0 0 6px; color: var(--ink-soft); }
.intro-facts { list-style: none; margin: 6px 0 14px; padding: 0; display: grid; gap: 2px; font-size: 0.95rem; }
.stage-banner { margin: auto; display: grid; gap: 4px; text-align: center; font-size: 1.4rem; background: rgba(255, 248, 232, 0.96); padding: 18px 32px; border-radius: 20px; box-shadow: var(--shadow); animation: pop 0.4s; }

/* 題目卡 */
.q-card { background: rgba(255, 252, 244, 0.96); border-radius: var(--radius); padding: 10px 12px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.q-card.compact { padding: 6px 12px 8px; gap: 4px; }
.q-head { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.q-zh { margin: 0; color: var(--ink-soft); font-size: 0.92rem; font-weight: 600; }
.hint-zh { margin: 0; color: var(--accent); font-weight: 700; }
.q-emoji { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.q-emoji span { font-size: 3.6rem; }
.q-emoji small { margin-top: 2px; font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.q-en-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.q-en { margin: 0; font-size: clamp(1.3rem, 5.2vw, 1.9rem); font-weight: 800; line-height: 1.25; }
.speak-btn, .line-say { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--accent); background: #fff; font-size: 1.2rem; line-height: 1; padding: 0; }
.line-say { width: 36px; height: 36px; font-size: 1rem; margin-right: 6px; border-width: 1px; }
.compact .q-emoji span { font-size: 2.4rem; }

.passage { background: repeating-linear-gradient(#fffdf5, #fffdf5 31px, #e7dcc2 32px); border: 2px solid #e2d3b0; border-radius: 12px; padding: 8px 12px 10px; }
.passage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.passage-head b { font-size: 1.05rem; color: var(--accent); }
.p-line { margin: 0; display: flex; align-items: center; min-height: 36px; font-size: 1.05rem; line-height: 1.35; padding: 2px 0; }
.p-line.gap { color: var(--coral); font-weight: 800; letter-spacing: 0.15em; justify-content: center; }
.p-intro { margin: 0 0 4px; font-style: italic; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 1.05rem; }
.data-table th, .data-table td { border: 2px solid #d8c9a6; padding: 6px 10px; text-align: left; }
.data-table thead th { background: var(--accent); color: #fff; }
.data-table tbody th { background: #fbefcf; font-weight: 700; }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.options.long, .options.n3 { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 12px; text-align: left; border-radius: 14px;
  border: 3px solid #cdb994; background: #fff; font-size: 1.12rem; font-weight: 700; box-shadow: 0 3px 0 rgba(74, 52, 38, 0.22);
  transition: transform 0.08s, background 0.12s;
}
.opt:hover:not(:disabled) { background: #fff3d1; }
.opt:active:not(:disabled) { transform: translateY(2px); }
.opt-no { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.85rem; text-align: center; line-height: 26px; }
.opt-text { min-width: 0; overflow-wrap: anywhere; }
.opt.ok { background: #c9f2d8; border-color: var(--good); }
.opt.reveal { background: #d9f5e3; border-color: var(--good); animation: blinkborder 0.7s 2; }
.opt.bad { background: #ffd8cf; border-color: var(--bad); }
.opt:disabled { color: inherit; }

/* 落葉 */
.fall-field {
  position: relative; flex: 1; min-height: 190px; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(#bfe6ff55, #fff8e855); border: 2px dashed rgba(74, 52, 38, 0.25);
}
.leaf {
  position: absolute; top: 0; height: 58px; padding: 0 6px; border: 0; background: none; will-change: transform; display: flex; align-items: center; justify-content: center;
}
.leaf > span:nth-child(2) {
  display: flex; align-items: center; justify-content: center; width: calc(100% - 12px); height: 52px; border-radius: 14px 26px 14px 26px; border: 3px solid #a85a1d;
  background: linear-gradient(135deg, #ffc65c, #ff9a3c); font-size: 1.3rem; font-weight: 800; color: #5b2d0b; box-shadow: 0 3px 0 rgba(120, 60, 10, 0.35);
}
.leaf-no { position: absolute; left: 10px; top: 0; z-index: 1; width: 20px; height: 20px; border-radius: 50%; background: #5b2d0b; color: #fff; font-size: 0.72rem; line-height: 20px; text-align: center; }
.leaf.ok > span:nth-child(2) { background: #8be0ae; border-color: var(--good); }
.leaf.reveal > span:nth-child(2) { background: #8be0ae; border-color: var(--good); animation: blinkborder 0.7s 3; }
.leaf.bad > span:nth-child(2) { background: #ff9d8a; border-color: var(--bad); }
.leaf.fade, .leaf.gone { opacity: 0.25; }
.ground { flex: none; height: 14px; margin-top: -8px; border-radius: 8px; background: repeating-linear-gradient(90deg, #5fbf63 0 14px, #4ea853 14px 28px); }

/* 打地鼠 */
.whack-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 10px; padding: 4px; }
.hole { position: relative; height: 104px; overflow: hidden; border-radius: 16px; background: linear-gradient(#c8e8b8, #9ccf8a); border: 2px solid #5f8f4e; }
.dirt { position: absolute; left: 4%; right: 4%; bottom: -14px; height: 40px; border-radius: 50%; background: #6b4a2f; box-shadow: inset 0 8px 0 #7e5a3b; z-index: 2; pointer-events: none; }
.mole {
  position: absolute; left: 6%; right: 6%; bottom: 12px; min-height: 76px; z-index: 1; border: 3px solid #5b3a1f; border-radius: 22px 22px 8px 8px;
  background: linear-gradient(#b07a4a, #8a5a33); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 6px 8px; gap: 0;
  transform: translateY(125%); transition: transform 0.16s ease-out; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.hole.up .mole { transform: translateY(0); pointer-events: auto; }
.mole-face { font-size: 1.3rem; line-height: 1; }
.mole-text { font-size: 1.05rem; font-weight: 800; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.mole.ok { background: linear-gradient(#59c785, #2e9e5b); }
.mole.reveal { background: linear-gradient(#59c785, #2e9e5b); animation: blinkborder 0.7s 3; }
.mole.bad { background: linear-gradient(#ee7a61, #c8452a); }
.mole:disabled { color: #fff; }

/* 拼句 */
.slot-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; min-height: 76px; border-radius: 14px; background: repeating-linear-gradient(#fffdf5, #fffdf5 40px, #e7dcc2 41px); border: 2px solid #e2d3b0; align-content: flex-start; }
.slot { min-width: 54px; height: 52px; border: 2px dashed #bfa779; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.5); }
.slot.filled { border-style: solid; border-color: transparent; background: transparent; min-width: 0; }
.slot.ok .chip { background: #c9f2d8; border-color: var(--good); }
.slot.bad .chip { background: #ffd8cf; border-color: var(--bad); }
.chip-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; min-height: 64px; border-radius: 14px; background: rgba(74, 52, 38, 0.08); }
.chip { min-height: 52px; padding: 4px 14px; border-radius: 12px; border: 3px solid #cdb994; background: #fff; font-size: 1.15rem; font-weight: 800; box-shadow: 0 3px 0 rgba(74, 52, 38, 0.22); }
.chip:active:not(:disabled) { transform: translateY(2px); }
.build-tools { display: flex; justify-content: flex-end; }

/* 排序 */
.seq-list { display: grid; gap: 8px; }
.seq-card { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border: 3px solid #cdb994; border-radius: 14px; background: #fff; text-align: left; font-size: 1.08rem; font-weight: 600; box-shadow: 0 3px 0 rgba(74, 52, 38, 0.22); }
.seq-badge { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px dashed #bfa779; text-align: center; line-height: 26px; font-weight: 800; color: #fff; }
.seq-card.placed { background: #d9f5e3; border-color: var(--good); }
.seq-card.placed .seq-badge { background: var(--good); border: 2px solid var(--good); }
.seq-card.reveal { background: #fff3d1; border-color: var(--gold); }
.seq-card.reveal .seq-badge { background: var(--gold); border-color: var(--gold); }
.seq-card.wrong-flash { background: #ffd8cf; border-color: var(--bad); }
.next-row { display: flex; justify-content: center; }

/* 記憶牌 */
.match-legend { display: flex; justify-content: center; gap: 12px; font-size: 0.85rem; font-weight: 700; }
.lg { padding: 0 10px; border-radius: 999px; color: #fff; }
.lg.base { background: #2f7fc4; }
.lg.past { background: #e2862b; }
.match-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-content: start; }
.mcard { position: relative; min-height: 92px; border: 3px solid var(--ink); border-radius: 16px; background: linear-gradient(135deg, #7a5cc9, #4d3a96); color: #fff; box-shadow: 0 4px 0 rgba(43, 33, 66, 0.5); padding: 4px; }
.mcard-back { font-size: 2rem; }
/* 蓋著的牌也用顏色區分原形（藍）與過去式（橘），與上方圖例一致：每次翻一藍一橘即可 */
.mcard.base:not(.open) { background: linear-gradient(135deg, #4d8fd8, #24589c); }
.mcard.past:not(.open) { background: linear-gradient(135deg, #f0a24a, #b9631a); }
.mcard-front { display: none; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; gap: 2px; }
.mcard-front b { font-size: 1.3rem; overflow-wrap: anywhere; }
.mcard-front small { font-size: 0.75rem; opacity: 0.92; }
.mcard.open .mcard-back { display: none; }
.mcard.open .mcard-front { display: flex; }
.mcard.open { animation: flip 0.28s; }
.mcard.base.open { background: linear-gradient(135deg, #5fb1f0, #2f7fc4); }
.mcard.past.open { background: linear-gradient(135deg, #ffb457, #e2862b); }
.mcard.done { opacity: 0.8; border-color: var(--good); box-shadow: 0 0 0 4px #9be3b8; }

/* 結算與彈窗 */
#modal-root { position: relative; z-index: 40; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 12px 12px calc(var(--footer-h) + 12px + env(safe-area-inset-bottom, 0px)); background: rgba(30, 20, 50, 0.55);
}
.modal { width: min(94vw, 460px); max-height: 100%; display: flex; flex-direction: column; background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4); animation: pop 0.25s; }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 2px dashed #d8c9a6; }
.modal-head h2 { margin: 0; font-family: var(--font-title); font-size: 1.3rem; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; }
.modal-foot { flex: none; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 10px 14px 14px; }
.result-body { display: grid; gap: 6px; justify-items: center; text-align: center; }
.result-mascot { width: 110px; height: 110px; object-fit: contain; }
.result-stars { display: flex; gap: 6px; font-size: 2.6rem; line-height: 1; }
.rs { color: #cfc3ad; transform: scale(0.4); opacity: 0; transition: transform 0.3s, opacity 0.3s; }
.rs.show { opacity: 1; transform: scale(1); }
.rs.show[data-on="1"] { color: #f5b301; text-shadow: 0 2px 0 #b57f00; }
.result-note { margin: 0; font-weight: 800; font-size: 1.15rem; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; margin: 4px 0; width: 100%; }
.result-stats div { background: #fff; border-radius: 12px; padding: 4px 8px; }
.result-stats dt { font-size: 0.78rem; color: var(--ink-soft); }
.result-stats dd { margin: 0; font-size: 1.25rem; font-weight: 800; }
.new-best { margin: 0; color: var(--coral); font-weight: 800; }
.result-pass { margin: 0; font-size: 0.8rem; color: var(--ink-soft); }
.settings { display: grid; gap: 10px; }
.set-row { display: grid; grid-template-columns: 6.5em 1fr 3.2em; align-items: center; gap: 8px; min-height: 44px; }
.set-row.check { grid-template-columns: 28px 1fr; }
.set-row input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--accent); }
.set-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
.set-row output { font-variant-numeric: tabular-nums; text-align: right; }
.reset-area { margin-top: 6px; padding-top: 10px; border-top: 2px dashed #d8c9a6; display: grid; gap: 8px; justify-items: start; }
.reset-area .row { display: flex; gap: 10px; flex-wrap: wrap; }
.reset-area .warn { margin: 0; color: var(--bad); font-weight: 700; }
.reset-area .done { margin: 0; color: var(--good); font-weight: 700; }
.install-steps { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.install-steps li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; }
.step-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; }

/* 特效層 */
#fx-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; width: 10px; height: 14px; border-radius: 2px; animation: confetti 1s ease-out forwards; }
.float-text { position: absolute; transform: translate(-50%, -50%); font-size: 1.8rem; font-weight: 900; text-shadow: 0 2px 0 #fff, 0 4px 10px rgba(0, 0, 0, 0.3); animation: floatup 1.1s ease-out forwards; white-space: nowrap; }
.float-text.good { color: #1f9d55; }
.float-text.bad { color: #d9482b; }
.float-text.combo { color: #ff7a00; font-size: 1.5rem; }
.flash { position: absolute; inset: 0; animation: flashanim 0.45s ease-out forwards; }
.flash.good { background: radial-gradient(circle, rgba(80, 220, 140, 0.0) 40%, rgba(80, 220, 140, 0.45)); }
.flash.bad { background: radial-gradient(circle, rgba(255, 90, 60, 0.0) 40%, rgba(255, 90, 60, 0.5)); }
.banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); max-width: 92vw; padding: 14px 22px; border-radius: 18px; background: linear-gradient(135deg, #7a5cc9, #e0698f); color: #fff; font-size: 1.3rem; font-weight: 900; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); animation: pop 0.4s, fadeout 0.5s 2.6s forwards; }
.shake { animation: shake 0.45s; }
.shake-still { outline: 4px solid var(--bad); outline-offset: 2px; }
.pulse { animation: pulse 0.4s; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes blink { 50% { opacity: 0.45; } }
@keyframes blinkborder { 50% { box-shadow: 0 0 0 6px #7be0a6; } }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes floatup { 0% { transform: translate(-50%, -30%) scale(0.6); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }
@keyframes flashanim { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }

/* 動畫減弱：保留顏色、圖示、文字等視覺回饋 */
:root[data-reduce-motion="true"] *, :root[data-reduce-motion="true"] *::before, :root[data-reduce-motion="true"] *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important;
}
:root[data-reduce-motion="true"] .menu-mascot { animation: none; }
:root[data-reduce-motion="true"] .float-text { animation: none; opacity: 1; transform: translate(-50%, -50%); }
:root[data-reduce-motion="true"] .flash { animation: none; opacity: 0.6; }
:root[data-reduce-motion="true"] .pulse { outline: 3px solid var(--accent); }
:root[data-reduce-motion="true"] .banner { animation: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .menu-mascot { animation: none; }
  .float-text { animation: none; opacity: 1; transform: translate(-50%, -50%); }
  .flash { animation: none; opacity: 0.6; }
  .banner { animation: none; }
}

/* 響應式 */
@media (min-width: 700px) and (min-height: 900px) {
  html { font-size: 120%; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
  .hud { padding: 4px 6px; gap: 6px; }
  .hud-title span { font-size: 0.9rem; }
  .hud-stats { gap: 6px; }
  .hud-score { font-size: 1.15rem; }
  .q-emoji span { font-size: 3rem; }
  .options { gap: 8px; }
  .opt { font-size: 1.02rem; padding: 6px 8px; min-height: 54px; }
  .opt-no { display: none; }
  .mole-text { font-size: 0.95rem; }
}
@media (min-width: 640px) {
  .lv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lv-btn { grid-template-columns: 1fr; grid-template-areas: "img" "title" "meta" "stars"; justify-items: center; text-align: center; padding: 22px 8px 14px; }
  .lv-btn .lv-img { width: 72px; height: 72px; }
  .whack-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .match-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .options.n3:not(.long) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root { --top-h: 44px; }
  .menu { flex-direction: row; flex-wrap: wrap; gap: 4px 20px; }
  .menu-mascot { width: 110px; }
  .title { font-size: 2rem; }
  .q-emoji span { font-size: 2.2rem; }
  .hud-mascot, .hud-mascot img { width: 36px; height: 36px; }
  .opt { min-height: 48px; }
  .hole { height: 70px; }
  .dirt { height: 28px; bottom: -10px; }
  .mole { min-height: 50px; bottom: 8px; padding: 2px 4px 6px; }
  .mole-face { font-size: 0.95rem; }
  .mole-text { font-size: 0.95rem; }
  .whack-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .match-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .mcard { min-height: 70px; }
  .feedback { min-height: 40px; padding: 2px 10px; }
  .feedback:empty { display: none; }
  .compact .q-zh, .hud-stats small { display: none; }
  .q-card { padding: 6px 10px 8px; gap: 6px; }
  .stage { gap: 6px; }
  .intro { padding: 8px 16px 12px; }
  .intro-scene { width: 64px; height: 64px; }
  .intro .scene-emoji { font-size: 3rem; }
  .modal-body { padding: 8px 12px; }
  /* 手機橫向的閱讀題：短文／表格在左、選項在右，減少上下捲動 */
  .q-card:has(.passage) { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .q-card:has(.passage) > .q-head { grid-column: 1 / -1; }
  .q-card:has(.passage) .q-en { font-size: 1.2rem; }
  .q-card:has(.passage) .options { grid-template-columns: 1fr; gap: 6px; }
  .q-card:has(.passage) .opt { min-height: 44px; font-size: 1rem; }
  .q-card:has(.passage) .p-line { min-height: 32px; }
}
