/* 勇者大冒險 — 文字介面樣式
 * 原則：字級 ≥ 20px、按鈕 ≥ 44×44px、對比足夠（WCAG 2.2 AA）、手機／平板橫向與桌機都能用。
 * 字型只用系統內建（不連字型服務）。 */
:root {
  --win-bg: #1d2b5e;
  --win-bg2: #2a3d80;
  --win-border: #f4f1e6;
  --text: #fffdf5;
  --muted: #d9e2ff;
  --accent: #ffd34d;
  --good: #7be08a;
  --bad: #ffb0a0;
  --sea: #4aa3df;
  --sand: #f3e1b5;
  --leaf: #6cbf4a;
  --focus: #ffe066;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Heiti TC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0e1430; overflow: hidden; overscroll-behavior: none; }
body { touch-action: manipulation; }
body { font-family: var(--font); font-size: 20px; color: var(--text); -webkit-text-size-adjust: 100%; }
#game { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#game canvas { image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#layer { pointer-events: none; position: absolute; inset: 0; }
#layer > * { pointer-events: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { color: #fff; padding: 24px; }
[hidden] { display: none !important; }

/* ---------- 視窗（DQ 風藍底白框） ---------- */
.win {
  background: linear-gradient(180deg, var(--win-bg2), var(--win-bg));
  border: 4px solid var(--win-border);
  border-radius: 12px;
  box-shadow: 0 0 0 3px #0b1236, 0 8px 24px rgba(0, 0, 0, .45);
  color: var(--text);
  padding: 14px 18px;
}
.win h2 { margin: 0 0 10px; font-size: 26px; color: var(--accent); }
.win h3 { margin: 12px 0 6px; font-size: 22px; color: var(--accent); }
.win p { margin: 6px 0; line-height: 1.55; }
.small { font-size: 20px; color: var(--muted); }

/* ---------- 按鈕 ---------- */
button, .btn {
  font: inherit; font-size: 21px; min-height: 48px; min-width: 48px;
  padding: 8px 18px; border-radius: 10px; cursor: pointer;
  border: 3px solid var(--win-border); background: #3956b0; color: var(--text);
  box-shadow: 0 3px 0 #0b1236; touch-action: manipulation;
}
button:hover { background: #4a69c8; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #0b1236; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #e0782e; border-color: #fff3d6; }
button.primary:hover { background: #f08a3e; }
button.good { background: #2f8f4a; }
button.ghost { background: transparent; }
button[aria-pressed="true"], button.selected { background: #f2c14e; color: #2a1e22; border-color: #fff; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }

/* ---------- 遮罩與面板 ---------- */
.modal-back { position: absolute; inset: 0; background: rgba(6, 10, 30, .55); display: flex; align-items: center; justify-content: center; padding: 10px; }
/* v0.9.3 放大地圖開著時也能走：遮罩變淡、點得穿（搖桿在遮罩上方照常可用） */
/* v0.9.5：原本被「#layer > * { pointer-events: auto }」（id 選擇器比較強）蓋掉，遮罩其實點不穿 → 點面板外的遊戲畫面不能走。選擇器加上 #layer */
#layer > .modal-back.pass, .modal-back.pass { background: rgba(6, 10, 30, .18); pointer-events: none; }
#layer > .modal-back.pass > *, .modal-back.pass > * { pointer-events: auto; }
.panel { width: min(920px, 96vw); max-height: 94vh; overflow: auto; }
.panel.narrow { width: min(620px, 96vw); }
.panel .close { float: right; }

/* ---------- 標題畫面 ---------- */
.title-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #6ab8e8 0%, #2f6fb0 55%, #1d2b5e 100%); text-align: center; padding: 16px; overflow: auto; }
.title-screen.has-art { background-size: cover; background-position: center; justify-content: flex-start; padding-top: 6vh; }
.title-screen.has-art .title-heroes { display: none; }
.title-screen.has-art .sub, .title-screen.has-art .note { text-shadow: 0 2px 4px #0b1236, 0 0 8px #0b1236; }
.title-screen.has-art .menu { margin-top: 30vh; }
.title-screen h1 { font-size: clamp(36px, 7vw, 64px); margin: 0 0 6px; color: #fffbe8; text-shadow: 0 4px 0 #1d2b5e, 0 0 18px rgba(255, 211, 77, .7); letter-spacing: 4px; }
.title-screen .sub { font-size: 22px; color: #fff3c8; margin-bottom: 18px; }
/* v1.0.1 已遊玩人數：副標題下面的小字（天空那一帶，不擋角色、開始按鈕、聯絡作者） */
.title-screen .title-count { margin: -10px 0 10px; padding: 3px 12px; border-radius: 999px; font-size: 16px; color: #fffbe8; background: rgba(11, 18, 54, .55); text-shadow: 0 1px 2px #0b1236; flex: none; }
.title-screen .title-count[hidden] { display: none; }
.title-screen .tap { font-size: 28px; padding: 16px 36px; animation: pulse 1.4s infinite; }
.title-screen .menu { display: flex; flex-direction: column; gap: 12px; width: min(420px, 90vw); }
.title-screen .note { font-size: 20px; color: #e6eeff; margin-top: 14px; max-width: 640px; }
.title-heroes { display: flex; gap: 18px; justify-content: center; margin: 6px 0 14px; min-height: 96px; align-items: flex-end; }
.title-heroes img, .sprite-preview { image-rendering: pixelated; height: 96px; }
@keyframes pulse { 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .title-screen .tap { animation: none; } }
/* v0.9.6 標題插畫動畫（title_anim.js）：WebGL 畫布墊在文字下面、蓋住靜態背景圖；第一格畫好才淡入（沒有 WebGL 就一直是靜態背景圖） */
.title-screen.has-art { isolation: isolate; }
.title-screen .title-anim { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .5s ease-out; }
.title-screen .title-anim.on { opacity: 1; }
/* v0.9.6 老闆：「開始」下移到主角腳邊。插畫是 cover 鋪滿、置中：原圖 1 像素 = max(100vw/1280, 100vh/720) 個 CSS 像素；
   男生最右邊在原圖 x≈693，也就是畫面中心往右 53 個原圖像素（4.15vw 或 7.37vh 取大的）。按鈕和說明放在他右邊、底部對齊腳，
   「聯絡作者」在最下面（標題畫面內距 16px＋聯絡作者約 68px），所以底部留 90px。 */
.title-screen .title-start { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title-screen .title-start .note { margin: 0; }
.title-screen .tap { word-break: keep-all; }
.title-screen.has-art .title-start { position: absolute; z-index: 1; margin: 0;
  left: calc(50% + max(4.15vw, 7.37vh) + 14px); width: min(460px, calc(50% - max(4.15vw, 7.37vh) - 26px));
  bottom: calc(90px + env(safe-area-inset-bottom)); }
.title-screen.has-art .title-start .tap { margin: 0; max-width: 100%; }
.title-screen.has-art .title-start .note { font-size: 18px; max-width: 100%; }
/* 窄的直式手機：男生右邊只剩約 110–150px → 按鈕兩行（點一下／開始）、說明字小一點 */
@media (orientation: portrait) and (max-width: 680px) {
  .title-screen.has-art .title-start { gap: 8px; }
  .title-screen.has-art .title-start .tap { font-size: 24px; padding: 10px 14px; line-height: 1.25; }
  .title-screen.has-art .title-start .note { font-size: 15px; padding: 6px 8px; line-height: 1.45; }
}
/* 矮的橫式（手機橫拿）：按鈕、說明小一點，不碰到上面的標題 */
@media (orientation: landscape) and (max-height: 500px) {
  .title-screen.has-art { padding-top: 3vh; }
  .title-screen.has-art .title-start { bottom: calc(78px + env(safe-area-inset-bottom)); gap: 6px; }
  .title-screen.has-art .title-start .tap { font-size: 22px; padding: 10px 24px; }
  .title-screen.has-art .title-start .note { font-size: 15px; padding: 4px 10px; }
  .title-screen.has-art .title-author { padding-top: 4px; }
}

.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field input[type=text], textarea {
  font: inherit; font-size: 24px; padding: 10px 12px; border-radius: 8px; border: 3px solid var(--win-border);
  background: #fffdf5; color: #1d2b5e; min-height: 52px; width: 100%;
}
textarea { font-size: 20px; min-height: 120px; }
.choice-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.choice-cards button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 18px; }
.choice-cards img, .choice-cards canvas { height: 72px; image-rendering: pixelated; }

/* ---------- 抬頭資訊（HUD） ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-card { padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 20px; border-width: 3px; }
.hud-card .name { font-weight: bold; color: var(--accent); }
.bar { position: relative; width: 120px; height: 16px; border: 2px solid #fff; border-radius: 8px; background: #0b1236; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--good); }
.bar.hp > i { background: #6be07a; }
.bar.mp > i { background: #6ab8ff; }
.bar.exp > i { background: var(--accent); }
.bar.boss > i { background: #ff8a6a; }
.bar.boss > b.phase-mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff3c8; opacity: .85; }   /* v0.9.3 頭目階段分隔線 */
.boss-need { color: #ffd34d; margin-top: 2px; }
.hud-buttons { display: flex; gap: 6px; }
.hud-buttons button { padding: 4px 10px; font-size: 20px; white-space: nowrap; }
.map-banner { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); font-size: 26px; padding: 8px 24px; pointer-events: none; animation: fadeout 2.6s forwards; }
@keyframes fadeout { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* 靠近 NPC 時的提示 */
#prompt { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); }
#prompt button { font-size: 22px; }

/* 觸控：虛擬搖桿（左下）、A／B 鍵（右下）。touch-action:none 避免拖曳時捲動或縮放 */
#pad { position: absolute; inset: auto 0 0 0; height: 0; pointer-events: none; }
.joystick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0%, rgba(29,43,94,.55) 70%); border: 4px solid rgba(255,255,255,.75);
  pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; }
.joystick .knob { width: 44%; height: 44%; border-radius: 50%; background: #f4f1e6; border: 4px solid #3956b0; box-shadow: 0 3px 0 #0b1236; pointer-events: none; transition: transform .06s; }
.abtn, .bbtn { position: absolute; border-radius: 50%; font-size: 30px; font-weight: bold; pointer-events: auto; touch-action: none; opacity: .92; padding: 0; }
.abtn { right: max(18px, env(safe-area-inset-right)); bottom: max(70px, env(safe-area-inset-bottom)); }
.bbtn { right: max(110px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); background: #6a6f8a; }
/* 有視窗開著時：搖桿與 A 鍵收起，B 鍵移到左上角（在遮罩上方，按了等於 Esc 關閉） */
#layer { z-index: 10; }
#pad { z-index: 30; }
#toasts { z-index: 40; }
body.modal-open #pad .joystick, body.modal-open #pad .abtn { display: none; }
body.modal-open #pad .bbtn { position: fixed; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: auto; bottom: auto; }
.qr-box { text-align: center; margin: 8px 0; }
.qr-box canvas.qr { width: min(360px, 80vw); height: auto; image-rendering: pixelated; border: 4px solid #fff; border-radius: 8px; }
.debug-tag { position: absolute; left: 8px; bottom: 8px; font-size: 20px; padding: 4px 12px; pointer-events: none; background: rgba(11,18,54,.85); }

/* ---------- 對話框 ---------- */
.dialog { position: absolute; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(900px, 96vw); display: flex; gap: 14px; align-items: flex-start; }
.dialog .portrait { width: 84px; height: 84px; flex: none; border: 3px solid var(--win-border); border-radius: 10px; background: #3a5aaa; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.dialog .portrait img { height: 80px; image-rendering: pixelated; }
.dialog .portrait .ph { font-size: 36px; line-height: 84px; }
.dialog .speaker { color: var(--accent); font-weight: bold; margin-bottom: 4px; }
.dialog .text { font-size: 23px; line-height: 1.55; min-height: 2.4em; }
.dialog .row { margin-top: 8px; }
.dialog .tailo { font-size: 20px; color: #bfe0ff; margin-top: 2px; font-style: italic; }
.dialog .huayu { font-size: 20px; color: var(--muted); margin-top: 2px; }

/* ---------- 台灣世界地圖 ---------- */
.worldmap { width: min(1000px, 98vw); max-height: 96vh; overflow: auto; }
.wm-body { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.worldmap .stage { position: relative; flex: none; background: linear-gradient(180deg, #4a90d4, #2a6ab8); border-radius: 10px; }
/* 直式台灣地圖：整張放得進畫面，用編號圓點標出地區 */
.worldmap .stage img { display: block; height: calc(96vh - 170px); min-height: 280px; width: auto; max-width: 92vw; border-radius: 10px; }
.worldmap .noimg-stage { width: 300px; height: 400px; }
.worldmap .stage .noimg { padding: 18px; color: #e6eeff; }
.worldmap .dot { position: absolute; transform: translate(-50%, -50%); width: 44px; height: 44px; min-width: 44px; padding: 0; border-radius: 50%; font-size: 22px; background: #e0782e; }
.worldmap .dot.here { background: #2f8f4a; }
.worldmap .dot-line { position: absolute; height: 2px; background: rgba(255, 255, 255, .85); transform-origin: 0 50%; pointer-events: none; box-shadow: 0 0 0 1px rgba(13, 21, 48, .6); }   /* v0.9.6 B04 推開的圓點連回真正的位置 */
.worldmap .dot.locked { background: #6a6f8a; }
.worldmap .regions { flex: 1; min-width: 260px; max-width: 420px; }
.worldmap .regions li { flex-direction: column; align-items: stretch; gap: 2px; }
.worldmap .pin { text-align: left; white-space: nowrap; }
.worldmap .pin.here { background: #2f8f4a; }
.worldmap .pin:disabled { opacity: .75; }

/* ---------- 題目視窗 ---------- */
.quiz { width: min(940px, 97vw); max-height: 96vh; overflow: auto; }
.quiz-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 6px; }
.chip { display: inline-block; padding: 2px 12px; border-radius: 999px; background: #f2c14e; color: #2a1e22; font-weight: bold; }
.stars { color: var(--accent); letter-spacing: 2px; }
.scene { background: rgba(255, 255, 255, .1); border-left: 6px solid var(--accent); padding: 8px 12px; border-radius: 6px; margin: 6px 0; line-height: 1.55; }
.stem { font-size: 25px; line-height: 1.55; margin: 10px 0; font-weight: bold; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 8px 0; }
.options button { text-align: left; font-size: 22px; padding: 10px 14px; min-height: 56px; }
.options button.erased { text-decoration: line-through; opacity: .35; }
.order-picked { display: flex; flex-wrap: wrap; gap: 8px; min-height: 56px; padding: 8px; border: 3px dashed #9fb4ff; border-radius: 10px; margin: 8px 0; }
.order-picked span { background: #f2c14e; color: #2a1e22; border-radius: 8px; padding: 6px 12px; font-size: 22px; }
.keypad { display: grid; grid-template-columns: repeat(5, minmax(56px, 1fr)); gap: 8px; max-width: 520px; margin: 8px 0; }
.keypad button { font-size: 26px; min-height: 56px; }
.number-display { font-size: 32px; background: #fffdf5; color: #1d2b5e; border-radius: 8px; padding: 6px 14px; min-width: 180px; min-height: 56px; display: inline-flex; align-items: center; border: 3px solid var(--win-border); }
.hintbox { background: rgba(255, 243, 200, .14); border: 2px dashed var(--accent); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.hintbox p { margin: 4px 0; }
.quiz-foot { position: sticky; bottom: -14px; background: var(--win-bg); border-top: 2px solid rgba(255, 255, 255, .25); padding: 4px 0 10px; margin: 6px -4px -6px; }
.quiz-foot .feedback { margin: 4px 0; min-height: 0; }
.feedback { min-height: 1.6em; font-size: 23px; margin: 8px 0; font-weight: bold; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.timer { position: relative; height: 22px; border: 3px solid #fff; border-radius: 11px; background: #0b1236; overflow: hidden; margin: 4px 0 8px; }
.timer > i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, #7be08a, #ffd34d); }
.timer.low > i { background: #ff8a6a; }
.timer.crit-zone::after { content: ""; position: absolute; top: 0; bottom: 0; left: 66.6%; border-left: 2px dashed rgba(255, 255, 255, .7); }
.timer .label { position: absolute; right: 8px; top: -2px; font-size: 18px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- 戰鬥 ---------- */
.battle-ui { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.battle-ui .status { min-width: 230px; }
.battle-ui .msg { flex: 1; min-width: 260px; font-size: 23px; min-height: 96px; line-height: 1.5; }
.battle-ui .cmds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 240px; }
.battle-top { position: absolute; left: 50%; top: max(8px, env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; padding: 6px 16px; }
.dmg-pop { color: #fff; }

/* ---------- 清單（背包、商店、手帳） ---------- */
.list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, .08); border-radius: 8px; padding: 6px 10px; flex-wrap: wrap; }
.list li .icon { width: 40px; height: 40px; image-rendering: pixelated; flex: none; border-radius: 6px; background: rgba(255, 255, 255, .12); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; overflow: hidden; }
.list li .icon img { width: 40px; height: 40px; image-rendering: pixelated; }
.list li .what { flex: 1; min-width: 180px; }
.list li .what b { color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button[aria-selected="true"] { background: #f2c14e; color: #2a1e22; }
.lights { display: flex; gap: 10px; flex-wrap: wrap; }
.lights span { padding: 6px 12px; border-radius: 999px; border: 2px solid #fff; }
.lights span.on { background: #ffd34d; color: #2a1e22; }
table.report { border-collapse: collapse; width: 100%; font-size: 20px; }
table.report th, table.report td { border-bottom: 1px solid rgba(255, 255, 255, .3); padding: 6px; text-align: left; }

/* ---------- 提示訊息 ---------- */
#toasts { position: absolute; right: 10px; top: 70px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
body.panel-open #toasts { top: auto; right: auto; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); align-items: center; }   /* 視窗開著時不蓋住右上角的「關閉」 */
.toast { padding: 8px 16px; font-size: 21px; animation: toastin .25s ease-out; max-width: 70vw; }
@keyframes toastin { from { transform: translateX(30px); opacity: 0; } }
.big-banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 34px; padding: 16px 32px; text-align: center; pointer-events: none; animation: fadeout 2.4s forwards; }

/* 窄螢幕（手機橫向）縮小一些間距，但字級不低於 20px */
@media (max-height: 460px) {
  .win { padding: 8px 12px; }
  .stem { font-size: 22px; margin: 6px 0; }
  .options button { min-height: 48px; font-size: 20px; }
  .dialog .text { font-size: 21px; }
  .battle-ui .msg { min-height: 64px; font-size: 21px; }
  .hud-card { font-size: 20px; padding: 4px 8px; }
  .bar { width: 80px; }
}

/* ---------- v0.4：任務按鈕數字、小地圖、名冊、旅店休息 ---------- */
.badge { display: inline-block; min-width: 24px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: #e0603a; color: #fff; font-size: 18px; line-height: 24px; text-align: center; }
.minimap { position: absolute; right: max(8px, env(safe-area-inset-right)); top: 60px; padding: 3px; min-width: 0; min-height: 0; border-radius: 8px; background: rgba(11, 18, 54, .75); line-height: 0; pointer-events: auto; }
.minimap canvas { display: block; border-radius: 4px; image-rendering: auto; }
.minimap-panel { width: auto; max-width: min(1000px, 97vw); }
/* v0.9.6（47 號 B13、B14）放大地圖：面板依內容寬度、靠左放 → 右邊露出遊戲畫面（平板橫向也點得到），右上角的小地圖按鈕也點得到（再點一次＝關掉）；直向時人物清單排到地圖下面、面板留出下方的搖桿 */
.modal-back.pass.mm-wrap { justify-content: flex-start; }
.minimap-panel .mm-side { flex: 0 1 280px; }
@media (orientation: portrait) {
  .modal-back.pass.mm-wrap { justify-content: center; align-items: flex-start; padding-top: calc(var(--hud-h, 88px) + 4px); }
  .minimap-panel { max-height: calc(100vh - var(--hud-h, 88px) - 190px); }
  .minimap-panel .mm-side { flex: 1 1 100%; max-height: none; }
}
.mm-body { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.mm-body > .mm-map { flex: 0 1 auto; max-width: 100%; }   /* 寬度由 minimap.js 設成地圖寬，圖例跟著換行，名單排在右邊 */
.mm-body canvas { display: block; border: 3px solid #fff; border-radius: 8px; max-width: 100%; }
.mm-side { flex: 1; min-width: 200px; max-height: 62vh; overflow: auto; }
/* v0.9.5 片頭動畫：蓋滿全螢幕、16:9 置中；右下角「跳過」 */
.opening { position: fixed; inset: 0; z-index: 120; background: #000; display: flex; align-items: center; justify-content: center; pointer-events: auto;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.opening:focus { outline: none; }   /* v0.9.6 B09 焦點在片頭畫面本身 */
.opening-stage { position: relative; background: #000; overflow: hidden; touch-action: manipulation; }
.opening-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.opening-skip { position: absolute; right: 2%; bottom: 3.5%; min-height: 48px; min-width: 104px; padding: 6px 18px; font-size: clamp(18px, 2.2vw, 24px); font-weight: bold;
  letter-spacing: 2px; background: rgba(18, 26, 62, .72); border: 3px solid #f4f1e6; border-radius: 10px; box-shadow: none; }
.opening-skip:hover, .opening-skip:focus-visible { background: rgba(42, 61, 128, .92); }
.opening-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #d9e2ff; }
.opening-loading[hidden] { display: none; }
body.opening-on #pad, body.opening-on #hud, body.opening-on #prompt { visibility: hidden; }
.mm-body canvas.minimap-big { cursor: crosshair; touch-action: manipulation; }   /* v0.9.5 點放大地圖就走過去 */
.map-banner.place-banner { background: #9e1a14; color: #ffd95a; border-color: #e0b040; }   /* v0.9.5 地標提示：比照匾額紅底金字 */
.list.compact li { padding: 4px 8px; }
.book-icon.unknown img, .book-icon.unknown span { filter: brightness(0) opacity(.55); }
.done-quests summary { cursor: pointer; font-size: 22px; color: var(--accent); margin: 10px 0; min-height: 44px; display: flex; align-items: center; }
.inn-veil { position: absolute; inset: 0; background: rgba(5, 8, 25, 0); transition: background .45s; display: flex; align-items: center; justify-content: center; pointer-events: auto; z-index: 50; }
.inn-veil.on { background: rgba(5, 8, 25, .82); }
.inn-veil div { color: #fffbe8; font-size: 30px; opacity: 0; transition: opacity .45s; }
.inn-veil.on div { opacity: 1; }
@media (max-height: 460px) { .minimap { top: 52px; } .minimap canvas { max-height: 70px; width: auto; } }

/* v0.5 大地圖載入進度條 */
.load-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 80vw); padding: 14px 18px; z-index: 45; pointer-events: none; }
.load-bar .label { font-size: 20px; margin-bottom: 8px; text-align: center; }
.load-bar .track { height: 16px; border-radius: 8px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.load-bar .fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd34d, #ffb02e); transition: width .15s; }

/* v0.7 頭目生氣（換階段）：紅色、會抖動的橫幅，和金色的「等級提升」明顯不同 */
.rage-banner { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 34px; font-weight: bold; padding: 14px 30px; text-align: center; pointer-events: none;
  color: #fff; background: rgba(150, 20, 20, .9); border: 4px solid #ff8a7a; border-radius: 14px; animation: rageshake .12s 6 alternate, fadeout 2.4s forwards; }
@keyframes rageshake { from { margin-left: -6px; } to { margin-left: 6px; } }

/* v0.7 設定頁：目前語音、讓聲音更自然 */
.voice-now { align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-tips summary { cursor: pointer; font-weight: bold; margin: 6px 0; }
.voice-tips li { margin: 4px 0; line-height: 1.5; }

/* v0.7.2 標題畫面的聯絡作者、回饋視窗 */
.title-screen { overflow-y: auto; }
.title-screen .title-author { margin: auto 0 0; padding: 14px 12px max(10px, env(safe-area-inset-bottom)); font-size: 15px; color: #e6eeff; text-shadow: 0 1px 3px #0b1236, 0 0 6px #0b1236; text-align: center; flex: none; }
.author-mail { color: #ffe08a; text-decoration: underline; word-break: break-all; }
.feedback-panel { width: min(760px, 96vw); }
.feedback-panel .fb-text, .feedback-panel .fb-copy { width: 100%; box-sizing: border-box; font-size: 18px; }
.feedback-panel .fb-check { align-items: flex-start; gap: 8px; margin: 10px 0; flex-wrap: nowrap; }
.feedback-panel .fb-check input { width: 22px; height: 22px; flex: none; }
.feedback-panel a.btn { display: inline-flex; align-items: center; text-decoration: none; background: #e0782e; border-color: #fff3d6; color: #fff; }
.feedback-panel .fb-preview { white-space: pre-wrap; font-size: 14px; max-height: 30vh; overflow: auto; background: rgba(0, 0, 0, .2); padding: 8px; border-radius: 6px; }

/* v0.7.2 視窗開著時，視窗打開前的提示泡泡先藏起來（關掉視窗後再出現），不會蓋住視窗內容 */
body.modal-open #toasts .toast.bg { display: none; }

/* v0.8 瀏覽器縮放提示（只在電腦版、縮放不是 100% 左右時出現） */
.title-screen .zoom-hint { display: flex; align-items: center; gap: 10px; font-size: 18px; padding: 8px 10px 8px 16px; margin: 0 12px 12px; max-width: min(640px, 94vw); flex: none; }
/* v1.0.6 家長設定的存檔提醒：黃色框、比一般小字醒目 */
.save-warn { margin: 10px 0; padding: 8px 12px; border: 2px solid #ffd34d; border-radius: 10px; background: rgba(255, 211, 77, .14); font-size: 20px; line-height: 1.55; }
.save-warn strong { display: block; color: #ffe08a; margin-bottom: 2px; }
/* v1.0.6「存檔有限」提醒：選單按鈕下面的小框（不蓋住按鈕；按「知道了」收起來） */
.title-screen .save-tip { display: flex; align-items: center; gap: 10px; font-size: 18px; line-height: 1.45; text-align: left; padding: 8px 10px 8px 14px; margin: 14px 12px 0; max-width: min(900px, 94vw); flex: none; border-color: #ffd34d; }
.title-screen .save-tip .save-tip-icon { font-size: 24px; flex: none; }
.title-screen .save-tip .save-tip-close { min-height: 44px; min-width: 44px; padding: 4px 12px; font-size: 18px; flex: none; }
@media (orientation: landscape) and (max-height: 500px) { .title-screen .save-tip { font-size: 15px; margin-top: 8px; } }
.title-screen .zoom-hint .zoom-close { min-height: 36px; min-width: 36px; padding: 2px 8px; font-size: 18px; flex: none; }

/* ---------------- v0.9 試玩稽核：版面修正 ---------------- */
/* 直向：遊戲畫面貼在 HUD 下面、滿寬（以前置中，上面空了一大塊） */
body.portrait #game { align-items: flex-start; padding-top: var(--hud-h, 96px); box-sizing: border-box; }
body.portrait .worldmap .stage img { height: auto; max-height: 46vh; max-width: 94vw; }
/* 地名框放到 HUD 下面，不蓋住魔力數字 */
.map-banner { top: calc(var(--hud-h, 88px) + 10px); }
/* 提示泡泡放在小地圖下面，不疊在小地圖上 */
#toasts { top: calc(var(--hud-h, 60px) + 130px); }
/* B 鍵：對話、題目（不是面板）時藏起來；面板開著時放左下角（面板下方留空間），不再蓋住左上角的名字或關閉鈕 */
body.modal-open:not(.panel-open) #pad .bbtn { display: none; }
body.modal-open.panel-open #pad .bbtn { position: fixed; top: auto; right: auto; left: max(8px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom)); width: 60px !important; height: 60px !important; }
#pad:not([hidden]) ~ #layer .panel { padding-bottom: 76px; }
/* 標題畫面的說明文字加半透明底，壓在插畫上也看得清楚 */
.title-screen .note { background: rgba(11, 18, 54, .62); padding: 6px 14px; border-radius: 10px; }
/* 小連結的點擊區至少 44px */
.author-mail { display: inline-block; line-height: 44px; min-height: 44px; vertical-align: middle; }
.voice-tips summary { min-height: 44px; line-height: 44px; }
/* 地圖載入框不蓋在其他視窗上 */
body.modal-open .load-bar { display: none; }

/* v0.9.1 小地圖下方的「寶箱：還剩 N 個」 */
.minimap { display: flex; flex-direction: column; align-items: center; }
.minimap .mm-caption { display: block; font-size: 14px; line-height: 1.3; color: #fff3c8; padding: 3px 4px 1px; white-space: nowrap; }
.minimap .mm-caption[hidden] { display: none; }
.minimap .mm-level { display: block; font-size: 14px; line-height: 1.3; color: #9fe0ff; padding: 1px 4px 3px; white-space: nowrap; }   /* v0.9.3 建議等級 */
.minimap .mm-level[hidden] { display: none; }

/* ---- v1.0 第一批（48 號 v2）：立志小考、轉職清單、技能選單 ---- */
.trial .trial-lamps { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 6px; font-size: 18px; color: #8a93b8; }
.trial .lamp.on { color: #ffd34d; font-weight: bold; text-shadow: 0 0 8px rgba(255, 211, 77, .7); }
.trial .trial-timer > i { background: linear-gradient(90deg, #7cc4ff, #b8e0ff); }   /* 倒數不用紅色、不變色 */
.trial .trial-timer .label { color: #0b1236; text-shadow: none; font-weight: bold; }
.trial .feedback.soft { color: #ffe9a8; }
.trial .trial-novoice { color: #ffe9a8; margin: 0 0 6px; }
.trial .trial-score { font-size: 24px; font-weight: bold; margin: 6px 0; }
.trial .trial-units { margin: 4px 0 8px 1.2em; font-size: 18px; }
.job-list li.soon { opacity: .75; }
.icon.silhouette { filter: brightness(0) opacity(.7); }
.job-card { margin-top: 2px; }
.job-card summary { cursor: pointer; font-size: 16px; color: #cfe0ff; }
.job-card .job-skills { margin: 2px 0 0 1.2em; padding: 0; }
.battle-ui .skill-btn .skill-icon { margin-right: 2px; }
.shop-tabs { display: flex; gap: 6px; margin: 4px 0; }
.shop-jobs { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 4px; }
.shop-jobs .icon { width: 24px; height: 24px; }
li.cant-use { opacity: .6; }
.fx-note { color: #ffd34d; }
