/* 夢想城市探險：全部樣式。系統字體堆疊，無外部資源。 */
:root {
  --ink: #26304a;
  --ink-soft: #55607d;
  --sky: #dff3ff;
  --orange: #ff8a3d;
  --orange-d: #d4661a;
  --blue: #3a86ff;
  --blue-d: #1f5fcc;
  --green: #2fbf71;
  --green-d: #1c8f52;
  --red: #ef5350;
  --red-d: #b8332f;
  --yellow: #ffd23f;
  --card: rgba(255, 255, 255, 0.94);
  --line: #d7e3f3;
  --radius: 18px;
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-en: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(#bfe6ff, #eaf8ff);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
[lang="en"] { font-family: var(--font-en); }
button { font-family: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid #1a4fd6; outline-offset: 2px; }
img { max-width: 100%; }

/* ───────── 版面骨架 ───────── */
#app {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: #cfeeff;
  background-size: cover;
  background-position: center bottom;
}
#app[data-screen="title"] { background-image: linear-gradient(rgba(255,255,255,.05), rgba(255,255,255,.05)), url("../assets/img/bg_title.webp"); }
#app[data-screen="map"] { background-image: linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.5)), url("../assets/img/bg_title.webp"); }
#app[data-screen="map"]:has(#screen-map.lit) { background-image: linear-gradient(rgba(10,15,50,.25), rgba(10,15,50,.15)), url("../assets/img/bg_night.webp"); }
#app[data-screen="result"] { background-image: linear-gradient(rgba(255,255,255,.4), rgba(255,255,255,.4)), url("../assets/img/bg_title.webp"); }
#app[data-screen="play"] { background-image: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,.65)), var(--section-bg, none); }

#toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 6px max(12px, env(safe-area-inset-left)) 6px max(12px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
  z-index: 5;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.toolbar-title { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-pause { font-size: 24px; }

#screens { flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column; }
.screen { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px max(14px, env(safe-area-inset-left)); }

#site-footer {
  flex: none;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12.5px;
  line-height: 1.45;
  color: #2e3650;
  background: rgba(255, 255, 255, 0.96);
  border-top: 2px solid var(--line);
  position: relative;
  z-index: 50;
}
#site-footer a { color: #1346b8; font-weight: 700; }

/* ───────── 按鈕 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px; padding: 0 26px;
  font-size: 1.15rem; font-weight: 800; letter-spacing: .04em;
  border: 0; border-radius: 16px;
  color: #fff; background: var(--blue);
  box-shadow: 0 5px 0 var(--blue-d), 0 8px 14px rgba(20, 40, 90, .2);
  transition: transform .08s, box-shadow .08s, filter .15s;
  user-select: none; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active, .btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-d); }
.btn.primary { background: var(--orange); box-shadow: 0 5px 0 var(--orange-d), 0 8px 14px rgba(120, 60, 10, .25); }
.btn.primary:active, .btn.primary.pressed { box-shadow: 0 1px 0 var(--orange-d); }
.btn.secondary { color: var(--ink); background: #fff; box-shadow: 0 5px 0 #b9c8e0, 0 8px 14px rgba(20, 40, 90, .12); }
.btn.secondary:active, .btn.secondary.pressed { box-shadow: 0 1px 0 #b9c8e0; }
.btn.danger { background: var(--red); box-shadow: 0 5px 0 var(--red-d); }
.btn.huge { min-height: 64px; padding: 0 44px; font-size: 1.5rem; }
.btn.small { min-height: 46px; padding: 0 16px; font-size: 1rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-icon {
  flex: none; display: inline-grid; place-items: center;
  width: 46px; height: 46px; padding: 0;
  font-size: 26px; color: var(--ink);
  background: #fff; border: 0; border-radius: 50%;
  box-shadow: 0 3px 0 #b9c8e0, 0 4px 10px rgba(20, 40, 90, .15);
  transition: transform .08s;
}
.btn-icon:active, .btn-icon.pressed { transform: translateY(3px); box-shadow: 0 0 0 #b9c8e0; }
.btn-icon.speak { color: #fff; background: var(--blue); box-shadow: 0 3px 0 var(--blue-d); }

/* ───────── 標題畫面 ───────── */
#screen-title { display: grid; place-items: center; }
.title-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 640px; padding: 18px 22px 24px; text-align: center;
  background: rgba(255, 255, 255, 0.82); border-radius: 28px;
  box-shadow: 0 10px 30px rgba(20, 50, 100, .22);
  backdrop-filter: blur(4px);
}
.title-mascot { width: clamp(120px, 28vh, 240px); height: auto; filter: drop-shadow(0 6px 6px rgba(0,0,0,.18)); animation: bob 2.4s ease-in-out infinite; }
.logo {
  margin: 0; font-size: clamp(2.1rem, 8vw, 3.6rem); font-weight: 900; letter-spacing: .06em;
  color: var(--orange); -webkit-text-stroke: 2px #fff; paint-order: stroke fill;
  text-shadow: 0 4px 0 #b5521a, 0 8px 12px rgba(0, 0, 0, .18);
}
.tagline { margin: 0; font-size: clamp(1rem, 3.4vw, 1.3rem); font-weight: 700; color: var(--ink-soft); }
.grade-badge { margin: 0; padding: 4px 16px; font-weight: 800; color: #fff; background: var(--green); border-radius: 999px; }

/* ───────── 選關地圖 ───────── */
.map-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; max-width: 1000px; margin: 0 auto 10px; }
.map-head h2 { margin: 0; font-size: 1.5rem; }
.map-stats { display: flex; gap: 10px; flex-wrap: wrap; font-weight: 800; }
.map-stats span { padding: 4px 14px; background: var(--card); border-radius: 999px; box-shadow: 0 2px 6px rgba(20, 40, 90, .12); }
.map-sections { display: grid; gap: 14px; max-width: 1000px; margin: 0 auto; }
.district { padding: 10px 12px 14px; background: var(--card); border-radius: 22px; box-shadow: 0 6px 16px rgba(20, 50, 100, .15); border-left: 10px solid var(--dc, var(--orange)); }
.district.d1 { --dc: #ff9f43; } .district.d2 { --dc: #2e86de; } .district.d3 { --dc: #ee5a8f; } .district.d4 { --dc: #10ac84; }
.district header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.district h3 { margin: 0; font-size: 1.2rem; color: var(--dc); }
.district-theme { color: var(--ink-soft); font-size: .92rem; font-weight: 700; }
.plot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.plot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px 8px; min-height: 150px;
  background: linear-gradient(#fff, #f2f7ff); border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 #c7d6ee; transition: transform .1s;
}
.plot.open:hover { transform: translateY(-3px); border-color: var(--dc); }
.plot:active { transform: translateY(2px); }
.plot-no { position: absolute; top: 4px; left: 6px; display: grid; place-items: center; width: 28px; height: 28px; font-weight: 900; color: #fff; background: var(--dc); border-radius: 50%; }
.plot-img { width: min(100%, 92px); height: auto; aspect-ratio: 1; object-fit: contain; }
.plot.locked .plot-img { filter: grayscale(1) brightness(.35) contrast(.8); opacity: .55; }
.plot.open:not(.built) .plot-img { filter: grayscale(.9) brightness(.75); opacity: .85; }
.plot.built { border-color: #ffd23f; background: linear-gradient(#fffbe6, #fff3c4); }
.plot-lock { position: absolute; top: 34%; font-size: 34px; color: #fff; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.plot-name { font-weight: 900; font-size: 1rem; }
.plot-title { font-size: .78rem; font-weight: 700; color: var(--ink-soft); line-height: 1.25; text-align: center; }
.plot-score { display: flex; align-items: center; gap: 4px; font-size: .85rem; }
.plot-score.muted { color: var(--ink-soft); font-weight: 700; }
.plot-stars { display: inline-flex; color: #d7dce6; font-size: 15px; }
.plot-stars .s.on { color: #ffb400; }
.map-lit { max-width: 1000px; margin: 14px auto 4px; padding: 12px 16px; text-align: center; font-size: 1.25rem; font-weight: 900; color: #fff4b8; background: rgba(20, 20, 70, .72); border-radius: 18px; }
#screen-map.lit .district { background: rgba(255, 252, 230, .93); box-shadow: 0 0 22px rgba(255, 220, 90, .55); }

/* ───────── 遊戲中：HUD、計時、舞台 ───────── */
#screen-play { position: relative; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.hud { flex: none; display: flex; align-items: center; gap: 10px; max-width: 920px; width: 100%; margin: 0 auto; }
.hud-spacer { flex: 1; }
.hud-stat { display: flex; flex-direction: column; align-items: center; padding: 2px 12px; background: var(--card); border-radius: 14px; min-width: 76px; }
.hud-label { font-size: .7rem; font-weight: 700; color: var(--ink-soft); }
.hud-stat b { font-size: 1.3rem; line-height: 1.1; }
.hud-stat b.bump { animation: bump .3s; }
.hud-lives { display: flex; gap: 2px; font-size: 22px; }
.heart.on { color: #ff5a6e; } .heart.off { color: #c8cfdc; }
.hud-lives .timed { padding: 3px 10px; font-size: .85rem; font-weight: 800; color: #fff; background: var(--blue); border-radius: 999px; }
.hud-combo { padding: 3px 12px; font-weight: 900; color: #fff; background: linear-gradient(90deg, #ff7a18, #ff4d6d); border-radius: 999px; }
.hud-combo.pop { animation: bump .45s; }
.hud-mascot { width: 52px; height: 52px; object-fit: contain; }

.timer { position: relative; flex: none; height: 18px; max-width: 920px; width: 100%; margin: 2px auto 0; overflow: hidden; background: rgba(255, 255, 255, .85); border: 2px solid #fff; border-radius: 999px; box-shadow: inset 0 1px 3px rgba(0,0,0,.15); }
.timer.idle { opacity: .25; }
.timer-num { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); font-size: .78rem; font-weight: 900; line-height: 1; color: #1d2b4a; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.timer[data-phase="read"] #timer-fill { background: #5b8def; animation: none; }
#timer-fill { height: 100%; transform-origin: left center; background: var(--green); border-radius: 999px; }
.timer[data-state="warn"] #timer-fill { background: #ffb400; }
.timer[data-state="danger"] #timer-fill { background: var(--red); animation: blink .5s infinite alternate; }
.progress-dots { flex: none; display: flex; justify-content: center; gap: 6px; }
.progress-dots i { width: 14px; height: 14px; background: rgba(255, 255, 255, .85); border: 2px solid #9db4d6; border-radius: 50%; }
.progress-dots i.on { background: var(--green); border-color: var(--green-d); }

.stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 920px; margin: 0 auto; overflow-y: auto; overflow-x: hidden; padding: 2px 2px 8px; }
.answer-reveal { flex: none; min-height: 1.5em; max-width: 920px; width: 100%; margin: 0 auto; text-align: center; font-weight: 900; font-size: 1.15rem; color: var(--green-d); }
.answer-reveal:empty { min-height: 0; }
#screen-play.paused .stage { filter: blur(6px); pointer-events: none; }

.qbox { padding: 10px 14px; background: var(--card); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(20, 50, 100, .14); }
.prompt-row { display: flex; align-items: center; gap: 12px; }
.prompt { display: flex; flex-direction: column; gap: 4px; }
.prompt-text { font-size: clamp(1.25rem, 4.6vw, 2rem); font-weight: 800; line-height: 1.4; }
.prompt-zh, .prompt-hint { font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); }
.blank { display: inline-block; min-width: 3.2ch; margin: 0 4px; text-align: center; color: var(--orange-d); border-bottom: 4px solid var(--orange); }

/* 選項 */
.opts { display: grid; gap: 12px; }
.opts.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.opts.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts-sentences { grid-template-columns: 1fr !important; }
.opt {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 96px; padding: 12px 8px;
  font-weight: 900; font-size: 1.3rem; color: var(--ink);
  background: #fff; border: 4px solid #cfdcf0; border-radius: 20px;
  box-shadow: 0 5px 0 #b9c8e0; transition: transform .08s, background .15s;
  touch-action: manipulation;
}
.opt:hover:not(:disabled) { border-color: var(--blue); transform: translateY(-2px); }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #b9c8e0; }
.opt-key { position: absolute; top: 5px; left: 8px; font-size: .8rem; font-weight: 800; color: #8a96b3; }
.opt-emoji { font-size: clamp(44px, 11vw, 72px); line-height: 1.1; }
.opt-label { font-size: clamp(1rem, 3.4vw, 1.35rem); }
.opt-sub { font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
.opt-prices .opt-label, .opt-receipts .opt-label { font-size: clamp(1.5rem, 6vw, 2.2rem); }
.opt-words .opt-label { font-size: clamp(1.1rem, 4vw, 1.6rem); }
.opt-sentences { flex-direction: row; justify-content: flex-start; min-height: 64px; padding: 10px 18px 10px 34px; text-align: left; }
.opt-sentences .opt-label { font-size: clamp(1.05rem, 3.6vw, 1.5rem); }
.opt.correct, .opt.done.correct { background: #d9f7e6; border-color: var(--green); box-shadow: 0 5px 0 var(--green-d); animation: pop .5s; }
.opt.wrong { background: #ffe0df; border-color: var(--red); box-shadow: 0 5px 0 var(--red-d); animation: shake .5s; }
.opt.reveal { background: #e9fff2; border-color: var(--green); animation: glow 0.9s ease-in-out 2; }
.opt:disabled:not(.correct):not(.wrong):not(.reveal) { opacity: .6; }

/* 價目表／文本 */
.board, .doc-menu, .doc-poster { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.board li, .doc-menu li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #fff8dd; border: 2px dashed #e6c35c; border-radius: 12px; font-weight: 800; }
.doc-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.doc-emoji { font-size: 1.8rem; }
.doc-word { flex: 1; min-width: 0; font-size: 1.05rem; }
.doc-price { font-size: 1.15rem; color: #c2410c; }
.doc { margin-top: 6px; padding: 10px 12px; background: #fffef7; border: 3px solid #f0d98a; border-radius: 16px; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc-head h3 { margin: 0; font-size: 1.2rem; }
.scroll-x { overflow-x: auto; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 1.1rem; font-weight: 700; text-align: center; }
.doc-table th, .doc-table td { padding: 6px 10px; border: 2px solid #ecd78a; }
.doc-table thead th { background: #ffe9a3; }
.doc-table tbody th { background: #fff3c4; }
.doc-poster li { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: #e9f6ff; border-radius: 12px; font-size: 1.1rem; font-weight: 800; }
.doc-label { min-width: 4.5em; color: var(--ink-soft); }
.doc-value { color: var(--blue-d); }
.doc-sms { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.bubble { display: flex; flex-direction: column; max-width: 86%; padding: 6px 12px; font-size: 1.05rem; font-weight: 700; border-radius: 16px; }
.bubble.left { align-self: flex-start; background: #e8eefc; border-bottom-left-radius: 4px; }
.bubble.right { align-self: flex-end; background: #d9f7e6; border-bottom-right-radius: 4px; }
.bubble-name { font-size: .78rem; color: var(--ink-soft); }
.doc-card { margin-top: 4px; padding: 6px 12px; background: repeating-linear-gradient(#fffef7 0 30px, #e7efff 30px 32px); border-radius: 10px; }
.doc-card p { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 32px; }

/* 排序 */
.sentence-line { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 88px; padding: 12px; background: #fff; border: 4px dashed #9db4d6; border-radius: 18px; }
.sentence-line.correct { border-color: var(--green); background: #e9fff2; }
.sentence-line.wrong { border-color: var(--red); background: #fff0ef; animation: shake .5s; }
.tile-pool { display: flex; flex-wrap: wrap; gap: 10px; min-height: 64px; padding: 6px 2px; }
.tile { min-height: 52px; padding: 6px 16px; font-size: clamp(1.1rem, 4vw, 1.5rem); font-weight: 800; color: var(--ink); background: #fff3c4; border: 3px solid #f0c94a; border-radius: 14px; box-shadow: 0 4px 0 #d7a91c; touch-action: manipulation; }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #d7a91c; }
.sentence-line .tile { background: #e5f0ff; border-color: #7aa6ff; box-shadow: 0 4px 0 #4f7fe0; }
.reorder-actions { display: flex; justify-content: flex-end; }

/* 付錢 */
.shop-counter { display: flex; align-items: center; justify-content: center; gap: 16px; }
.shop-item { font-size: 64px; }
.price-tag { min-width: 120px; padding: 8px 20px; text-align: center; font-size: 2rem; font-weight: 900; color: #7a5200; background: #ffe48a; border: 4px solid #e6b800; border-radius: 14px; transform: rotate(-3deg); }
.price-tag.shown { animation: pop .4s; }
.coin-tray { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; min-height: 70px; padding: 8px; background: rgba(255, 255, 255, .9); border: 4px dashed #9db4d6; border-radius: 18px; }
.coin-tray.correct { border-color: var(--green); background: #e9fff2; }
.coin-tray.wrong { border-color: var(--red); background: #fff0ef; animation: shake .5s; }
.pay-total { text-align: center; font-size: 1.5rem; font-weight: 900; }
.pay-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.coins { display: flex; justify-content: center; align-items: center; gap: clamp(8px, 3vw, 22px); flex-wrap: wrap; }
.coin { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 900; color: #5a3b00; border: 4px solid rgba(0, 0, 0, .18); box-shadow: 0 5px 0 rgba(0, 0, 0, .25), inset 0 3px 6px rgba(255, 255, 255, .6); touch-action: manipulation; }
button.coin { padding: 0; transition: transform .08s; }
button.coin:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.coin-1 { width: 64px; height: 64px; font-size: 1.3rem; background: radial-gradient(circle at 30% 30%, #ffd9a8, #d98a3d); }
.coin-5 { width: 74px; height: 74px; font-size: 1.5rem; background: radial-gradient(circle at 30% 30%, #fff1b8, #e0b73a); }
.coin-10 { width: 84px; height: 84px; font-size: 1.7rem; background: radial-gradient(circle at 30% 30%, #fff, #c9a64f); }
.coin-50 { width: 96px; height: 96px; font-size: 1.9rem; background: radial-gradient(circle at 30% 30%, #fff, #b9c3d1); color: #2e3b52; }
.coin.mini { width: 40px; height: 40px; font-size: .95rem; border-width: 3px; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }

/* 付錢版面 */
.pay-layout, .pay-left, .pay-right { display: flex; flex-direction: column; gap: 10px; }

/* 閱讀時間：先讀文本，按「讀好了」或時間到才出現題目與選項 */
.read-phase { position: sticky; bottom: -2px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; padding: 8px 0 4px; font-weight: 800; color: var(--ink-soft); background: linear-gradient(rgba(235, 247, 255, 0), rgba(235, 247, 255, .96) 22%); }
.read-go { min-height: 48px; }

/* 閱讀題：問題固定在上方、選項固定在底部，中間的文本可捲動（小螢幕捲到文本底部時仍看得到問題） */
.qtype-read > .prompt { position: sticky; top: -2px; z-index: 2; margin: -10px -14px 0; padding: 8px 14px 6px; background: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.stage[data-kind="choice"]:has(.doc) .opts, .stage[data-kind="choice"]:has(.board) .opts { position: sticky; bottom: -2px; padding: 8px 0 4px; background: linear-gradient(rgba(235, 247, 255, 0), rgba(235, 247, 255, .96) 22%); }
.stage[data-kind="choice"]:has(.doc) .opt { min-height: 54px; padding: 6px 8px; }

/* 配對 */
.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-head { text-align: center; font-weight: 900; color: var(--ink-soft); }
.match-item { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 6px 12px; font-weight: 900; background: #fff; border: 4px solid #cfdcf0; border-radius: 18px; box-shadow: 0 4px 0 #b9c8e0; }
.match-item .opt-emoji { font-size: 2.2rem; }
.match-item.selected { border-color: var(--blue); background: #e5f0ff; transform: scale(1.04); }
.match-item.done { opacity: .75; }
.match-item.wrong { border-color: var(--red); background: #ffe0df; }
.match-item.reveal { border-color: #ffb400; background: #fff3c4; }

/* 翻牌 */
.memory-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 640px; width: 100%; margin: 0 auto; }
.mem-card { aspect-ratio: 1 / 1; padding: 0; background: none; border: 0; perspective: 700px; }
.mem-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .35s; }
.mem-card.flipped .mem-inner, .mem-card.done .mem-inner { transform: rotateY(180deg); }
.mem-face { position: absolute; inset: 0; display: grid; place-items: center; padding: 4px; text-align: center; border: 4px solid #fff; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 5px 0 rgba(0, 0, 0, .2); }
.mem-back { font-size: 2.4rem; color: #fff; background: repeating-linear-gradient(45deg, #ff9f43 0 12px, #ffb86b 12px 24px); }
.mem-front { transform: rotateY(180deg); background: #fff; }
.mem-front .opt-emoji { font-size: clamp(36px, 9vw, 64px); }
.mem-front .opt-label { font-size: clamp(.95rem, 3.2vw, 1.35rem); font-weight: 900; }
.mem-card.done .mem-front { background: #d9f7e6; border-color: var(--green); }

/* 下落接字 */
.catch-field { position: relative; flex: 1 1 260px; min-height: 240px; overflow: hidden; background: linear-gradient(rgba(255,255,255,.35), rgba(190,230,255,.5)); border: 4px solid rgba(255,255,255,.9); border-radius: 22px; box-shadow: inset 0 0 20px rgba(60, 120, 200, .2); }
.fall-item { position: absolute; top: 0; display: flex; flex-direction: column; align-items: center; width: clamp(72px, 20vw, 110px); padding: 6px 4px; font-weight: 900; background: #fff; border: 4px solid #cfdcf0; border-radius: 18px; box-shadow: 0 4px 0 #b9c8e0; transform: translate(-50%, -110%); touch-action: manipulation; }
.fall-item .opt-emoji { font-size: clamp(34px, 8vw, 52px); }
.fall-item .opt-label { font-size: clamp(.8rem, 2.6vw, 1.05rem); }
.fall-item.gone { opacity: 0; transition: opacity .3s; }
.fall-item.correct { background: #d9f7e6; border-color: var(--green); animation: pop .5s; }
.fall-item.wrong { background: #ffe0df; border-color: var(--red); }
.fall-item.reveal { background: #e9fff2; border-color: var(--green); animation: glow .9s ease-in-out 2; }

/* 關前說明 */
.intro { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 12px; background: rgba(30, 50, 90, .45); backdrop-filter: blur(3px); }
.intro-card { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 520px; width: 100%; max-height: 100%; overflow-y: auto; padding: 16px 20px 20px; text-align: center; background: #fff; border-radius: 26px; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); animation: pop .4s; }
.intro-building { width: clamp(84px, 22vh, 150px); height: auto; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .2)); }
.intro-no { font-weight: 800; color: var(--ink-soft); }
.intro-card h2 { margin: 0; font-size: 1.6rem; }
.intro-card p { margin: 0; font-weight: 700; font-size: 1.1rem; }
.intro-meta { color: var(--ink-soft); font-size: .95rem !important; }
.intro-speed { padding: 4px 12px; color: #9a3412; background: #fff1d6; border-radius: 12px; font-size: 1rem !important; }

/* ───────── 結算 ───────── */
#screen-result { display: grid; place-items: center; }
.result-card { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 560px; width: 100%; padding: 18px 20px 22px; text-align: center; background: rgba(255, 255, 255, .95); border-radius: 28px; box-shadow: 0 12px 30px rgba(20, 50, 100, .28); animation: pop .45s; }
.result-title { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.result-card.win .result-title { color: var(--green-d); }
.result-card.lose .result-title { color: var(--red-d); }
.result-stars { display: flex; gap: 10px; font-size: clamp(48px, 14vw, 72px); }
.big-star { color: #d7dce6; transform: scale(.8); }
.big-star.on { color: #ffb400; }
.big-star.on.pop { animation: starPop .6s; transform: scale(1); }
.big-star.on:not(.pop) { color: #d7dce6; }
.result-building { display: flex; align-items: center; gap: 12px; }
.result-building img { width: clamp(72px, 18vh, 120px); height: auto; }
.result-card.lose .result-building img { filter: grayscale(1) brightness(.6); }
.result-building p { margin: 0; font-weight: 800; font-size: 1.1rem; text-align: left; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; width: 100%; margin: 0; }
.result-stats div { padding: 6px 10px; background: #eef5ff; border-radius: 14px; }
.result-stats dt { font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.result-stats dd { margin: 0; font-size: 1.4rem; font-weight: 900; }
.badge-new { margin-left: 6px; padding: 2px 8px; font-size: .75rem; color: #fff; background: var(--red); border-radius: 999px; vertical-align: middle; }
.result-goal { margin: 0; font-weight: 800; color: var(--ink-soft); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ───────── 對話框、提示 ───────── */
#modal-root { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.modal { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(20, 30, 60, .5); backdrop-filter: blur(3px); pointer-events: auto; }
.modal-panel { position: relative; display: flex; flex-direction: column; gap: 10px; width: min(480px, 100%); max-height: 100%; overflow-y: auto; padding: 20px 20px 18px; background: #fff; border-radius: 26px; box-shadow: 0 14px 34px rgba(0, 0, 0, .35); animation: pop .3s; }
.modal-title { margin: 0 40px 0 0; font-size: 1.5rem; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; font-size: 20px; }
.modal-body { font-size: 1.05rem; font-weight: 600; }
.modal-body p { margin: 0 0 8px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-label { flex: 0 0 8.5em; font-weight: 800; }
.row input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--orange); }
.range-out { width: 2.6em; text-align: right; font-weight: 800; }
.row.check { gap: 12px; }
.row.check input { width: 26px; height: 26px; accent-color: var(--orange); }
.danger-zone { margin-top: 6px; padding-top: 10px; border-top: 2px dashed var(--line); }
.danger-zone .muted { margin: 0 0 8px; color: var(--ink-soft); }
.confirm { padding: 12px; background: #fff0ef; border: 3px solid var(--red); border-radius: 16px; }
.confirm p { font-weight: 800; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.install-steps { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.install-steps li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: #eef5ff; border-radius: 14px; font-weight: 700; }
.step-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; font-size: 26px; color: #fff; background: var(--blue); border-radius: 12px; }

.toast { position: absolute; left: 50%; bottom: 14px; z-index: 45; max-width: min(92%, 560px); padding: 10px 18px; text-align: center; font-weight: 800; color: #fff; background: rgba(30, 40, 70, .92); border-radius: 16px; opacity: 0; transform: translate(-50%, 20px); transition: opacity .25s, transform .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.cheat { font-size: 1.3rem; color: #3a2a00; background: linear-gradient(90deg, #ffe066, #ffb347); }

/* ───────── 特效 ───────── */
#fx-layer { position: fixed; inset: 0; z-index: 2000; overflow: hidden; pointer-events: none; }
.float-text { position: absolute; font-size: 1.6rem; font-weight: 900; color: #1c8f52; text-shadow: 0 2px 0 #fff, 0 0 8px #fff; transform: translate(-50%, -50%); animation: floatUp 1.2s ease-out forwards; white-space: nowrap; }
.float-text.big { font-size: 2.4rem; color: #e8590c; }
.float-text.small { font-size: 1.05rem; }
.float-text.bad { color: #d6336c; }
.fx-ring { position: absolute; width: 20px; height: 20px; border: 6px solid; border-radius: 50%; transform: translate(-50%, -50%); animation: ring .7s ease-out forwards; }
.fx-ring.good { border-color: #2fbf71; } .fx-ring.bad { border-color: #ef5350; }
.fx-particle { position: absolute; width: 12px; height: 12px; border-radius: 50%; font-size: 22px; line-height: 12px; }
.fx-confetti { position: absolute; top: -20px; border-radius: 2px; }
.fx-flash { position: absolute; inset: 0; animation: flash .6s ease-out forwards; }
.fx-flash.good { box-shadow: inset 0 0 90px 10px rgba(47, 191, 113, .55); }
.fx-flash.bad { box-shadow: inset 0 0 90px 10px rgba(239, 83, 80, .5); }
.shake { animation: shake .5s; }
.pulse { animation: bump .5s; }
.mascot-img.mood-pop { animation: pop .5s; }

@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes blink { to { opacity: .55; } }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(47, 191, 113, .45); } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -230%) scale(1); } }
@keyframes ring { to { width: 130px; height: 130px; opacity: 0; } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes starPop { 0% { transform: scale(.3) rotate(-30deg); } 70% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes fadeOnly { 0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }

.big-star.on.pop { color: #ffb400; }

/* ───────── 減少動畫：保留顏色、文字與閃爍回饋，去掉位移與縮放 ───────── */
[data-motion="reduced"] .title-mascot,
[data-motion="reduced"] .mascot-img.mood-pop,
[data-motion="reduced"] .intro-card,
[data-motion="reduced"] .result-card,
[data-motion="reduced"] .modal-panel,
[data-motion="reduced"] .hud-stat b.bump,
[data-motion="reduced"] .hud-combo.pop,
[data-motion="reduced"] .pulse,
[data-motion="reduced"] .price-tag.shown { animation: none; }
[data-motion="reduced"] .shake,
[data-motion="reduced"] .opt.wrong,
[data-motion="reduced"] .sentence-line.wrong,
[data-motion="reduced"] .coin-tray.wrong { animation: none; outline: 5px solid var(--red); outline-offset: -3px; }
[data-motion="reduced"] .opt.correct,
[data-motion="reduced"] .fall-item.correct { animation: none; outline: 5px solid var(--green); outline-offset: -3px; }
[data-motion="reduced"] .opt.reveal,
[data-motion="reduced"] .fall-item.reveal { animation: none; outline: 5px dashed var(--green); outline-offset: -3px; }
[data-motion="reduced"] .float-text { animation: fadeOnly 1.4s forwards; transform: translate(-50%, -140%); }
[data-motion="reduced"] .fx-ring { animation: flash .8s forwards; width: 90px; height: 90px; }
[data-motion="reduced"] .fx-flash { animation: flash 1s forwards; }
[data-motion="reduced"] .mem-inner { transition: none; transform: none !important; }
[data-motion="reduced"] .mem-face { backface-visibility: visible; -webkit-backface-visibility: visible; }
[data-motion="reduced"] .mem-front { transform: none; opacity: 0; }
[data-motion="reduced"] .mem-card.flipped .mem-front, [data-motion="reduced"] .mem-card.done .mem-front { opacity: 1; }
[data-motion="reduced"] .big-star.on.pop { animation: none; }
[data-motion="reduced"] .btn, [data-motion="reduced"] .opt, [data-motion="reduced"] .plot { transition: none; }

/* ───────── 響應式 ───────── */
@media (max-width: 720px) {
  .plot-grid { grid-template-columns: repeat(2, 1fr); }
  .opts.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-menu { grid-template-columns: 1fr; }
  .hud-mascot { width: 46px; height: 46px; }
  .toolbar-title { max-width: 46vw; font-size: .95rem; }
  .row-label { flex-basis: 6.5em; }
  #site-footer { font-size: 12px; }
}
@media (max-width: 420px) {
  .opts.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .opt { min-height: 84px; padding: 8px 4px; }
  .btn.huge { padding: 0 30px; font-size: 1.35rem; }
  .coin-1 { width: 54px; height: 54px; } .coin-5 { width: 62px; height: 62px; }
  .coin-10 { width: 70px; height: 70px; } .coin-50 { width: 80px; height: 80px; }
  .match-item { padding: 6px 8px; }
}
@media (max-width: 520px) {
  .doc-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .doc-menu li { padding: 4px 6px; gap: 4px; }
  .doc-menu .doc-emoji { font-size: 1.4rem; }
  .doc-menu .doc-word { font-size: .88rem; }
  .doc-menu .doc-price { font-size: 1rem; }
  .board li { padding: 4px 6px; gap: 4px; }
}
@media (max-height: 520px) {
  #toolbar { min-height: 46px; padding-top: 3px; padding-bottom: 3px; }
  .btn-icon { width: 40px; height: 40px; font-size: 22px; }
  .screen { padding-top: 6px; padding-bottom: 6px; }
  #screen-play { gap: 3px; padding-top: 4px; }
  .hud-mascot { display: none; }
  .hud-stat { flex-direction: row; gap: 6px; padding: 0 10px; }
  .progress-dots { display: none; }
  .stage { gap: 6px; }
  .qbox { padding: 6px 10px; }
  .opt { min-height: 66px; padding: 6px; }
  .opt-emoji { font-size: 40px; }
  .opts { gap: 8px; }
  .title-card { padding: 10px 16px 14px; gap: 4px; }
  .title-mascot { width: 100px; }
  .btn.huge { min-height: 52px; }
  .shop-item { font-size: 40px; }
  .coin-1 { width: 48px; height: 48px; } .coin-5 { width: 54px; height: 54px; }
  .coin-10 { width: 60px; height: 60px; } .coin-50 { width: 68px; height: 68px; }
  .coin-tray { min-height: 50px; }
  .catch-field { min-height: 130px; }
  .intro-building { width: 70px; }
  .result-stars { font-size: 40px; }
  .result-card { gap: 6px; padding: 10px 16px; }
  .result-building img { width: 60px; }
  .tile { min-height: 44px; }
  .mem-card { aspect-ratio: 5 / 3; }
  .memory-grid { gap: 8px; }
  .sentence-line { min-height: 60px; }
  .modal-panel { padding: 12px 16px; }
  #site-footer { padding-top: 3px; padding-bottom: calc(3px + env(safe-area-inset-bottom)); font-size: 11.5px; }
}

/* 橫向手機：把兩塊內容並排，避免需要捲動 */
@media (max-height: 520px) and (min-width: 640px) {
  .pay-layout { flex-direction: row; align-items: flex-start; }
  .pay-left, .pay-right { flex: 1; min-width: 0; }
  .price-tag { min-width: 90px; padding: 2px 12px; font-size: 1.4rem; }
  .pay-total { font-size: 1.15rem; }
  .stage[data-kind="choice"]:has(.doc), .stage[data-kind="choice"]:has(.board) { display: grid; grid-template-columns: 1.25fr 1fr; align-items: start; gap: 10px; }
  .stage[data-kind="choice"]:has(.doc) .opts, .stage[data-kind="choice"]:has(.board) .opts { position: sticky; top: 0; bottom: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; background: none; }
  .stage[data-kind="choice"]:has(.doc) .read-phase { position: sticky; top: 0; bottom: auto; background: none; }
  .stage[data-kind="choice"]:has(.board) .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 全部通關後的夜間地圖：標題改為亮色以維持對比 */
#screen-map.lit .map-head h2 { color: #fff4b8; text-shadow: 0 2px 6px rgba(0, 0, 30, .8); }
