/* 月曆大冒險：樣式。純 CSS，無外部字型。 */
:root {
  --ink: #3b2f4a;
  --ink-soft: #6b5d7c;
  --paper: #fffaf0;
  --primary: #6c5ce7;
  --primary-d: #4f3fc4;
  --accent: #ff7a59;
  --ok: #27ae60;
  --ok-soft: #d6f5df;
  --bad: #e8445a;
  --bad-soft: #ffe0e4;
  --gold: #ffc83d;
  --theme: #6c5ce7;
  --theme-soft: #ece8ff;
  --footer-h: 32px;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(59, 47, 74, 0.18);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #dfe6ff var(--bg-img, none) center / cover no-repeat fixed;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.6));
  pointer-events: none;
  z-index: 0;
}
body[data-theme="menu"] { --bg-img: url("../assets/img/bg-menu.webp"); --theme: #6c5ce7; --theme-soft: #ece8ff; }
body[data-theme="spring"] { --bg-img: url("../assets/img/bg-spring.webp"); --theme: #e0709b; --theme-soft: #ffe4ee; }
body[data-theme="summer"] { --bg-img: url("../assets/img/bg-summer.webp"); --theme: #1c9ec9; --theme-soft: #dff4fc; }
body[data-theme="autumn"] { --bg-img: url("../assets/img/bg-autumn.webp"); --theme: #e07b1c; --theme-soft: #ffeedb; }
body[data-theme="winter"] { --bg-img: url("../assets/img/bg-winter.webp"); --theme: #4a76d6; --theme-soft: #e3ecff; }

button { font-family: inherit; color: inherit; }
:focus-visible { outline: 4px solid #1d6cff; outline-offset: 2px; }

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: var(--footer-h);
}

/* ---- 頂欄 ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 6px calc(10px + env(safe-area-inset-left, 0px));
  min-height: 52px;
}
.brand { font-weight: 900; font-size: 1.15rem; letter-spacing: 0.04em; color: var(--primary-d); text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8); flex: 1; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 3px solid var(--theme);
  background: #fff;
  color: var(--theme);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(59, 47, 74, 0.18);
  transition: transform 0.08s;
}
.icon-btn:active, .icon-btn.down { transform: translateY(2px) scale(0.96); box-shadow: 0 1px 0 rgba(59, 47, 74, 0.18); }

#main { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; overflow-y: auto; padding: 8px calc(14px + env(safe-area-inset-right, 0px)) 14px calc(14px + env(safe-area-inset-left, 0px)); }
#screen-game { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 6px; }

/* ---- 頁尾 ---- */
#site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 5px 10px calc(5px + env(safe-area-inset-bottom, 0px));
  background: rgba(40, 28, 70, 0.94);
  color: #f4efff;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}
#site-footer a { color: #ffd86b; font-weight: 700; }

/* ---- 按鈕 ---- */
.btn {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 999px;
  border: 3px solid var(--primary-d);
  background: #fff;
  color: var(--primary-d);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.big { min-height: 58px; font-size: 1.3rem; min-width: 220px; }
.btn.small { min-height: 44px; padding: 6px 16px; font-size: 0.95rem; }
.btn.ghost { background: rgba(255, 255, 255, 0.85); box-shadow: 0 3px 0 rgba(59, 47, 74, 0.14); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:not(.ghost) { background: var(--bad); color: #fff; }
.btn:active, .btn.down, .btn.pressed { transform: translateY(3px); box-shadow: 0 2px 0 rgba(59, 47, 74, 0.2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--theme);
  background: #fff;
  color: var(--theme);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(59, 47, 74, 0.18);
  flex: none;
}
.btn-round.big { width: 84px; height: 84px; }
.btn-round.big svg { width: 44px; height: 44px; }
.btn-round.small { width: 44px; height: 44px; }
.btn-round:active, .btn-round.down { transform: translateY(2px) scale(0.95); }

/* ---- 主選單 ---- */
.menu-cover {
  position: relative;
  max-width: 460px;
  margin: 18px auto 10px;
  padding: 54px 20px 22px;
  background: var(--paper);
  border-radius: 28px;
  border-top: 40px solid #ef5b5b;
  box-shadow: 0 10px 0 rgba(59, 47, 74, 0.16), 0 20px 40px rgba(59, 47, 74, 0.18);
  text-align: center;
}
.cover-rings { position: absolute; top: -52px; left: 0; right: 0; display: flex; justify-content: space-evenly; padding: 0 12%; }
.cover-rings i { width: 14px; height: 38px; border-radius: 8px; background: linear-gradient(90deg, #c9c9d6, #fff, #a5a5b8); border: 2px solid #8b8b9e; }
.menu-mascot { width: clamp(110px, 24dvh, 190px); height: auto; margin-top: -30px; cursor: pointer; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.18)); }
.menu-cover h1 { margin: 4px 0 0; font-size: clamp(2rem, 8vw, 2.8rem); color: var(--primary-d); letter-spacing: 0.06em; text-shadow: 0 3px 0 #ffd86b; }
.menu-sub { margin: 0; color: var(--ink-soft); font-weight: 700; }
.menu-bubble { margin: 10px auto 14px; max-width: 320px; padding: 8px 14px; background: var(--theme-soft); border-radius: 16px; font-weight: 700; }
.menu-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.menu-stars { margin: 14px 0 0; font-weight: 800; color: #b27d00; }

/* 矮螢幕（桌機 1280×720、小筆電、矮手機）：縮小封面留白，讓星數不必捲動就看得到 */
@media (max-height: 780px) {
  .menu-cover { margin-top: 12px; padding-top: 42px; border-top-width: 34px; }
  .cover-rings { top: -46px; }
  .menu-mascot { width: clamp(90px, 19dvh, 160px); margin-top: -34px; }
  .menu-cover h1 { font-size: clamp(1.9rem, 7vw, 2.5rem); }
  .menu-bubble { margin: 6px auto 10px; }
  .menu-buttons { gap: 10px; }
  .menu-stars { margin-top: 8px; }
}
@media (max-height: 660px) {
  .menu-bubble { display: none; }
  .menu-sub { margin-bottom: 10px; }
  .menu-mascot { width: clamp(80px, 17dvh, 120px); }
  .btn.big { min-height: 50px; }
}

/* ---- 選關 ---- */
.levels-head { text-align: center; margin: 4px 0 8px; }
.levels-head h2 { margin: 0; font-size: 1.5rem; color: var(--primary-d); text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9); }
.levels-sub { margin: 2px 0 0; font-weight: 700; color: var(--ink-soft); }
.levels-grid { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 12px; }
.level-section { background: rgba(255, 250, 240, 0.86); border-radius: 22px; padding: 10px 12px 14px; box-shadow: 0 6px 0 rgba(59, 47, 74, 0.12); }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; font-weight: 900; }
.section-emoji { font-size: 1.6rem; }
.section-name { font-size: 1.2rem; }
.section-topic { font-size: 0.95rem; color: var(--ink-soft); font-weight: 700; }
.section-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.level-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 6px 8px;
  min-height: 150px;
  border-radius: 14px;
  border: 3px solid var(--theme);
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 5px 0 rgba(59, 47, 74, 0.16);
  text-align: center;
  transition: transform 0.08s;
}
.level-tile:active, .level-tile.down { transform: translateY(3px); }
.level-tile.season-spring { --theme: #e0709b; }
.level-tile.season-summer { --theme: #1c9ec9; }
.level-tile.season-autumn { --theme: #e07b1c; }
.level-tile.season-winter { --theme: #4a76d6; }
.tile-top { align-self: stretch; margin: 0 -6px; padding: 2px 0; background: var(--theme); color: #fff; font-size: 0.8rem; font-weight: 800; }
.tile-num { font-size: 2.4rem; font-weight: 900; line-height: 1.1; color: var(--theme); }
.tile-title { font-weight: 800; font-size: 0.95rem; line-height: 1.2; }
.tile-mech { font-size: 0.75rem; color: var(--ink-soft); }
.tile-stars { color: #f5b301; font-size: 1.15rem; letter-spacing: 2px; margin-top: auto; }
.tile-best { font-size: 0.75rem; color: var(--ink-soft); font-weight: 700; }
.level-tile.locked { filter: grayscale(0.85); opacity: 0.75; }
.level-tile.cleared { background: #fffdf2; }

/* ---- 遊戲 HUD ---- */
.hud {
  display: grid;
  grid-template-columns: 44px 44px 1fr;
  align-items: center;
  gap: 4px 8px;
  padding: 2px 2px 4px;
}
.hud-mascot { width: 44px; height: 44px; object-fit: contain; }
.hud-main { min-width: 0; }
.hud-title { font-weight: 900; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-say { font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stats { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 900; }
.hud-stat { background: rgba(255, 255, 255, 0.9); border-radius: 999px; padding: 2px 12px; min-width: 52px; text-align: center; }
.hud-stat:empty { display: none; }
.lives { display: inline-flex; gap: 1px; font-size: 1.05rem; }
.combo { color: #d6501f; background: #fff2c2; border-radius: 999px; padding: 2px 10px; animation: comboPulse 0.5s; }
#hud-score.bump { display: inline-block; animation: bump 0.35s; }
.timer { height: 10px; margin: 2px 4px 6px; background: rgba(255, 255, 255, 0.7); border-radius: 8px; overflow: hidden; border: 2px solid rgba(59, 47, 74, 0.25); }
#timer-fill { height: 100%; transform-origin: left center; background: linear-gradient(90deg, #35c46b, #ffd43b); }
.timer.low #timer-fill { background: var(--bad); }
.stage { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 2px 2px 8px; }

/* ---- 選擇題 ---- */
.quiz { display: flex; flex-direction: column; gap: 10px; flex: 1; width: 100%; max-width: 780px; margin: 0 auto; min-height: 0; }
.q-card {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  border: 3px solid var(--theme);
  padding: 10px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 5px 0 rgba(59, 47, 74, 0.14);
}
.q-zh { margin: 0; font-weight: 800; color: var(--ink-soft); font-size: 0.98rem; }
.q-emoji { font-size: clamp(52px, 13dvh, 92px); line-height: 1.05; }
.q-emoji.small { font-size: clamp(36px, 8dvh, 56px); }
.q-text { font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 900; color: var(--primary-d); }
.q-hint { margin: 0; color: var(--ink-soft); font-weight: 700; }
.passage { width: 100%; text-align: left; background: #fffdf2; border: 2px dashed #e3c26a; border-radius: 14px; padding: 8px 12px; }
.passage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 900; color: #a77800; }
.passage-body { margin: 4px 0 0; font-size: 1.05rem; line-height: 1.55; font-weight: 600; }
.sent { background: none; border: 0; padding: 1px 2px; font: inherit; color: var(--ink); cursor: pointer; text-align: left; border-radius: 6px; }
.sent:hover, .sent:focus-visible { background: #ffe9a3; }
.q-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.q-options.n3 { grid-template-columns: 1fr; }
.opt, .match-item, .fall-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 66px;
  padding: 10px 10px 10px 30px;
  border-radius: 16px;
  border: 3px solid var(--theme);
  background: #fff;
  font-size: clamp(1.05rem, 4.2vw, 1.35rem);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(59, 47, 74, 0.16);
  transition: transform 0.08s, background 0.15s;
}
.opt:hover:not(:disabled), .match-item:hover:not(:disabled) { background: var(--theme-soft); }
.opt:active:not(:disabled) { transform: translateY(3px); }
.opt-key { position: absolute; left: 7px; top: 7px; width: 20px; height: 20px; border-radius: 50%; background: var(--theme); color: #fff; font-size: 0.75rem; display: grid; place-items: center; }
.opt-emoji { font-size: 2rem; line-height: 1; }
.opt-zh { font-size: 0.8rem; color: var(--ink-soft); font-weight: 700; }
.opt:disabled, .chip:disabled { cursor: default; }
.is-correct { background: var(--ok-soft) !important; border-color: var(--ok) !important; }
.is-wrong { background: var(--bad-soft) !important; border-color: var(--bad) !important; }
.reveal-correct { border-color: var(--ok) !important; background: var(--ok-soft) !important; animation: glowPulse 0.9s ease-in-out 2; }
.q-reveal { min-height: 40px; padding: 6px 12px; border-radius: 14px; text-align: center; font-weight: 800; font-size: 1.1rem; opacity: 0; }
.q-reveal.show { opacity: 1; }
.q-reveal.ok { background: var(--ok-soft); color: #1b7a42; }
.q-reveal.no { background: var(--bad-soft); color: #b3243a; }
.rv-text { font-weight: 900; }

/* ---- 排序 / 拼字 ---- */
.order-line { min-height: 70px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.92); border: 3px dashed var(--theme); }
.order-pool { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 4px; }
.order-tools { display: flex; justify-content: center; }
.chip { min-height: 52px; padding: 8px 16px; border-radius: 14px; border: 3px solid var(--theme); background: #fff; font-size: 1.3rem; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 rgba(59, 47, 74, 0.16); }
.chip.tile { min-width: 52px; padding: 8px 10px; font-size: 1.5rem; text-transform: none; }
.chip.placed { background: var(--theme-soft); }
.chip:active:not(:disabled) { transform: translateY(3px); }
.chip:disabled:not(.placed) { opacity: 0.35; }
.slot { display: inline-block; min-width: 70px; min-height: 52px; border-radius: 12px; border: 3px dashed rgba(59, 47, 74, 0.3); }
.slot.tile { min-width: 46px; }

/* ---- 打地鼠 ---- */
.whack { align-items: center; gap: 8px; }
.whack-target, .fall-prompt { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; background: rgba(255, 255, 255, 0.95); border: 3px solid var(--theme); border-radius: var(--radius); padding: 8px 12px; box-shadow: 0 5px 0 rgba(59, 47, 74, 0.14); }
.wt-text { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.whack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, max(240px, calc(100dvh - 360px))); max-width: 480px; aspect-ratio: 1; }
.hole { position: relative; overflow: hidden; border: 0; padding: 0; background: radial-gradient(ellipse at 50% 85%, #4a2c17 0 38%, rgba(0, 0, 0, 0) 40%), linear-gradient(#9be28a, #6cc15a); border-radius: 20px; cursor: pointer; min-width: 44px; min-height: 44px; }
.dirt { position: absolute; left: 4%; right: 4%; bottom: 0; height: 30%; border-radius: 50% 50% 0 0; background: #7b4a2a; z-index: 3; }
.mole { position: absolute; left: 12%; right: 12%; bottom: 14%; top: 8%; border-radius: 50% 50% 14% 14%; background: #a8703f; border: 3px solid #5b3517; z-index: 2; animation: molePop 0.22s ease-out; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6%; }
.mole-face { position: relative; width: 70%; height: 22%; }
.eye { position: absolute; top: 20%; width: 14%; aspect-ratio: 1; border-radius: 50%; background: #2a1a0e; }
.eye.l { left: 22%; }
.eye.r { right: 22%; }
.mole-sign { margin-top: 4%; max-width: 98%; background: #fff; border: 2px solid #5b3517; border-radius: 10px; padding: 1px 4px; font-weight: 900; font-size: clamp(0.7rem, 2.8vw, 1rem); text-align: center; line-height: 1.15; }
.mole-emoji { font-size: clamp(1.4rem, 7vw, 2.3rem); line-height: 1.1; display: block; }
.mole.hit { animation: moleHit 0.28s forwards; }
.mole.gone { animation: moleDown 0.28s forwards; }

/* ---- 下落接字 ---- */
.falling { gap: 8px; }
.fall-area { position: relative; flex: 1; min-height: 230px; overflow: hidden; border-radius: var(--radius); background: rgba(255, 255, 255, 0.45); border: 3px solid var(--theme); }
.fall-card { position: absolute; top: 0; min-height: 56px; padding: 14px 2px 6px; font-size: clamp(0.88rem, 3.3vw, 1.2rem); line-height: 1.15; text-align: center; }
.fall-card .opt-key { left: 3px; top: 3px; width: 16px; height: 16px; font-size: 0.62rem; }
.fall-card.gone { opacity: 0.2; pointer-events: none; }
.fall-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: repeating-linear-gradient(45deg, var(--bad) 0 10px, #ffb3be 10px 20px); }

/* ---- 配對 ---- */
.match-info { text-align: center; }
.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item { padding: 10px; min-height: 72px; }
.match-item.selected { background: #fff3c4; border-color: var(--gold); transform: scale(1.03); }
.match-item.matched { background: var(--ok-soft); border-color: var(--ok); opacity: 0.75; }
.match-item.right .opt-emoji { font-size: 1.6rem; }

/* ---- 翻牌 ---- */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 620px; margin: 0 auto; }
.mem-card { aspect-ratio: 1 / 1; padding: 0; border: 0; background: none; perspective: 700px; cursor: pointer; min-width: 44px; min-height: 44px; }
.mem-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.35s; }
.mem-card.flipped .mem-inner { transform: rotateY(180deg); }
.mem-back, .mem-front { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px; border: 3px solid var(--theme); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 4px 0 rgba(59, 47, 74, 0.16); }
.mem-back { background: repeating-linear-gradient(45deg, var(--theme) 0 10px, color-mix(in srgb, var(--theme) 80%, #fff) 10px 20px); color: #fff; font-size: 2rem; font-weight: 900; }
.mem-front { background: #fff; transform: rotateY(180deg); font-weight: 900; font-size: clamp(0.95rem, 3.6vw, 1.3rem); text-align: center; padding: 2px; }
.card-emoji { font-size: clamp(2rem, 9vw, 3.2rem); line-height: 1; }
.card-word { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.mem-card.matched .mem-front { background: var(--ok-soft); border-color: var(--ok); }
.mem-card.is-wrong .mem-front { background: var(--bad-soft); border-color: var(--bad); }

/* ---- 對話框 ---- */
#modal-root { position: relative; z-index: 500; }
.modal-overlay { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 14px 14px calc(var(--footer-h) + 14px); background: rgba(35, 24, 64, 0.58); animation: fadeIn 0.18s; }
.modal { width: 100%; max-width: 480px; max-height: calc(100dvh - var(--footer-h) - 28px); overflow-y: auto; background: var(--paper); border-radius: 26px; border-top: 16px solid var(--theme, #ef5b5b); padding: 16px 18px 18px; box-shadow: 0 12px 0 rgba(59, 47, 74, 0.2); animation: modalIn 0.22s ease-out; user-select: text; -webkit-user-select: text; }
.modal-title { margin: 0 0 8px; font-size: 1.35rem; color: var(--primary-d); text-align: center; }
.modal-body p, .modal-body li { margin: 6px 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.howto { padding-left: 1.3rem; text-align: left; }
.intro-sec { font-weight: 800; color: var(--theme); text-align: center; }
.intro-mech { text-align: center; font-weight: 900; font-size: 1.1rem; }
.intro-rule { text-align: center; font-weight: 700; }
.intro-facts { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: center; }
.intro-facts li { background: var(--theme-soft); border-radius: 999px; padding: 2px 12px; font-weight: 800; font-size: 0.9rem; }
.result { text-align: center; }
.result-head { font-size: 1.5rem; font-weight: 900; color: var(--primary-d); margin: 0; }
.result-stars { display: flex; justify-content: center; gap: 8px; font-size: 3.2rem; line-height: 1.1; }
.rstar { color: #d9d3e6; transition: color 0.2s, transform 0.3s; }
.rstar.on { color: #ffc400; transform: scale(1.2) rotate(-8deg); text-shadow: 0 3px 0 #d68a00; }
.result-score strong { font-size: 1.8rem; color: var(--accent); }
.result-bonus, .result-thr, .result-best, .result-combo { font-size: 0.9rem; color: var(--ink-soft); font-weight: 700; }
.result-reason { color: var(--bad); font-weight: 800; }
.result-final { font-weight: 900; color: #b27d00; }
.set-row { display: grid; grid-template-columns: 6.5em 1fr 3.2em; align-items: center; gap: 10px; padding: 8px 0; font-weight: 800; }
.set-row.toggle { grid-template-columns: 1fr auto; }
.set-row input[type="range"] { width: 100%; height: 32px; accent-color: var(--primary); }
.set-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--primary); }
.set-row output { text-align: right; font-variant-numeric: tabular-nums; }
.reset-box { margin-top: 10px; padding-top: 10px; border-top: 2px dashed rgba(59, 47, 74, 0.2); text-align: center; }
.confirm-text { color: var(--bad); font-weight: 800; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

#toast { position: fixed; left: 50%; bottom: calc(var(--footer-h) + 16px); transform: translateX(-50%) translateY(20px); z-index: 950; background: rgba(40, 28, 70, 0.92); color: #fff; padding: 8px 18px; border-radius: 999px; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: 92vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.secret-banner { position: fixed; top: calc(70px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 1100; background: linear-gradient(135deg, #ffd43b, #ff922b); color: #3b2f4a; font-weight: 900; font-size: 1.3rem; padding: 12px 22px; border-radius: 22px; box-shadow: 0 8px 0 rgba(59, 47, 74, 0.25); animation: bannerIn 0.4s, fadeOut 0.5s 3s forwards; text-align: center; max-width: 92vw; }

/* ---- 特效層 ---- */
#fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 900; }
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 901; overflow: hidden; }
.fx-float { position: absolute; transform: translate(-50%, -50%); font-size: 1.7rem; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 8px rgba(0, 0, 0, 0.25); animation: floatUp 1s ease-out forwards; white-space: nowrap; }
.fx-float.good { color: #7dff9b; }
.fx-float.bad { color: #ff9aa8; }
.fx-float.combo { color: #ffd43b; font-size: 1.4rem; }
.fx-glow { position: absolute; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; animation: fadeOut 0.7s forwards; }
.fx-flash { position: absolute; inset: 0; animation: fadeOut 0.5s forwards; }

.bounce { animation: bounce 0.5s; }
.shake { animation: shake 0.45s; }

/* ---- 動畫 ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 100% { transform: none; } 30% { transform: translateY(-10px) scale(1.06); } 60% { transform: translateY(2px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, -50%) scale(0.8); } 70% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -150%) scale(1.15); } }
@keyframes bump { 50% { transform: scale(1.35); color: #e8590c; } }
@keyframes comboPulse { from { transform: scale(0.6); } to { transform: scale(1); } }
@keyframes glowPulse { 50% { box-shadow: 0 0 0 8px rgba(39, 174, 96, 0.35), 0 5px 0 rgba(59, 47, 74, 0.16); } }
@keyframes molePop { from { transform: translateY(80%); } to { transform: none; } }
@keyframes moleHit { to { transform: translateY(30%) scale(0.9) rotate(8deg); opacity: 0; } }
@keyframes moleDown { to { transform: translateY(90%); opacity: 0.2; } }
@keyframes bannerIn { from { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(0.8); } to { opacity: 1; transform: translateX(-50%); } }

/* 動畫減弱：保留顏色／透明度的視覺回饋，去掉位移、縮放與搖晃 */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
.reduce-motion .fx-float { animation: fadeOut 1.1s ease-out forwards !important; transform: translate(-50%, -50%); }
.reduce-motion .fx-glow, .reduce-motion .fx-flash { animation: fadeOut 0.7s forwards !important; }
.reduce-motion .secret-banner { animation: fadeOut 0.5s 3s forwards !important; }
.reduce-motion .mem-card.flipped .mem-inner { transform: rotateY(180deg); }

/* ---- 響應式 ---- */
@media (min-width: 700px) {
  .hud { grid-template-columns: 44px 48px 1fr auto; }
  .hud-stats { grid-column: auto; }
  .hud-title { font-size: 1.15rem; }
}
@media (max-width: 560px) {
  .section-row { grid-template-columns: repeat(2, 1fr); }
  .level-tile { min-height: 138px; }
  .q-options { gap: 8px; }
  .match-board { gap: 8px; }
}
@media (orientation: portrait) {
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (orientation: landscape) and (max-height: 560px) {
  #topbar { min-height: 44px; padding-top: calc(3px + env(safe-area-inset-top, 0px)); padding-bottom: 3px; }
  .icon-btn { width: 40px; height: 40px; }
  .brand { font-size: 1rem; }
  .menu-cover { margin: 28px auto 6px; padding: 22px 16px 10px; border-top-width: 26px; max-width: 760px; display: grid; grid-template-columns: 1fr 1.4fr; grid-template-areas: "mascot title" "mascot sub" "mascot buttons" "stars buttons"; align-items: center; column-gap: 16px; text-align: center; }
  .cover-rings { top: -40px; }
  .cover-rings i { height: 30px; }
  .menu-cover h1 { font-size: 1.9rem; }
  .menu-cover .menu-bubble { display: none; }
  .menu-cover h1 { grid-area: title; }
  .menu-sub { grid-area: sub; margin-bottom: 8px; }
  .menu-buttons { grid-area: buttons; }
  .menu-stars { grid-area: stars; margin: 0; align-self: start; }
  .menu-cover .menu-mascot { grid-area: mascot; justify-self: center; height: auto; width: clamp(96px, 32dvh, 160px); margin: 0; }
  .menu-buttons { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .btn.big { min-height: 50px; min-width: 150px; font-size: 1.15rem; }
  .section-row { grid-template-columns: repeat(4, 1fr); }
  .level-tile { min-height: 120px; }
  .hud { grid-template-columns: 44px 40px 1fr auto; padding-bottom: 0; }
  .hud-stats { grid-column: auto; }
  .hud-mascot { width: 38px; height: 38px; }
  .timer { margin-bottom: 4px; }
  .quiz-choice, .quiz-order, .quiz-spell { flex-direction: row; flex-wrap: wrap; align-content: flex-start; align-items: stretch; }
  .quiz-choice .q-card { flex: 1 1 44%; }
  .quiz-choice .q-options { flex: 1 1 50%; align-content: start; }
  .quiz-choice .q-options.n3 { grid-template-columns: 1fr; }
  .quiz-choice .q-reveal, .quiz-order .q-reveal, .quiz-spell .q-reveal { flex: 1 1 100%; min-height: 34px; padding: 2px 10px; }
  .quiz-order .q-card, .quiz-spell .q-card, .quiz-order .order-line, .quiz-order .order-pool, .quiz-spell .order-line, .quiz-spell .order-pool { flex: 1 1 100%; }
  .q-emoji { font-size: clamp(36px, 14dvh, 64px); }
  .q-card { padding: 6px 10px; }
  .opt { min-height: 52px; padding-top: 6px; padding-bottom: 6px; }
  .whack { flex-direction: row; justify-content: center; align-items: center; }
  .whack-target { flex: 0 0 34%; flex-direction: column; }
  .whack-grid { width: min(60%, calc(100dvh - 215px)); }
  .falling { gap: 4px; }
  .fall-area { min-height: 140px; }
  .modal { max-height: calc(100dvh - var(--footer-h) - 16px); padding: 10px 16px 12px; }
  .memory-grid { grid-template-columns: repeat(6, 1fr); max-width: 760px; }
  .mem-card { max-height: calc((100dvh - 190px) / 2); aspect-ratio: auto; height: calc((100dvh - 190px) / 2); }
  .match-item { min-height: 54px; padding: 4px 8px; }
  .match-col { gap: 6px; }
}
@media (max-width: 420px) {
  .btn.big { min-width: 200px; }
  .brand { font-size: 1.05rem; }
  .fx-float { font-size: 1.4rem; }
}
