/* 美少女孟公廠：黃銅工坊主題 */
:root {
  --ink: #2a2622;
  --ink-soft: #5d554c;
  --cream: #fbf4e6;
  --paper: #fffaf0;
  --teal: #2c6e6a;
  --teal-deep: #1f3b3a;
  --brass: #c8963e;
  --brass-light: #f0d39b;
  --rose: #d9695a;
  --sky: #4c86c6;
  --good: #3f9a5a;
  --bad: #c9473b;
  --shadow: 0 6px 20px rgba(30, 20, 10, .25);
  --radius: 14px;
  --font: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --serif: 'Noto Serif TC', 'PMingLiU', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--teal-deep); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; }
#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; max-width: 1400px; margin: 0 auto; overflow: hidden; background: var(--cream); }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* 按鈕 */
.btn { border: 2px solid var(--teal-deep); background: var(--paper); color: var(--ink); padding: 10px 18px; border-radius: 999px; font-size: 16px; font-weight: 500; box-shadow: 0 3px 0 var(--teal-deep); transition: transform .08s, box-shadow .08s, background .2s; }
.btn:hover { background: var(--brass-light); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--teal-deep); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: #378781; }
.btn.big { font-size: 19px; padding: 14px 26px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row2 { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* 標題 */
#scr-title { align-items: center; justify-content: center; }
.title-bg { position: absolute; inset: 0; background: url(../assets/img/title.webp) center/cover; filter: saturate(1.1); }
.title-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(31,59,58,.1), rgba(31,59,58,.65)); }
.title-box { position: relative; text-align: center; color: #fff; padding: 24px; }
.title-gear { font-size: 64px; color: var(--brass-light); animation: spin 14s linear infinite; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.4); }
@keyframes spin { to { transform: rotate(360deg); } }
.logo { font-family: var(--serif); font-size: clamp(44px, 9vw, 96px); margin: 6px 0; letter-spacing: .08em; text-shadow: 0 4px 0 var(--teal-deep), 0 8px 24px rgba(0,0,0,.5); }
.logo span { color: var(--brass-light); }
.tagline { font-size: clamp(15px, 2.4vw, 20px); margin: 0 0 26px; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.title-menu { display: grid; gap: 12px; max-width: 320px; margin: 0 auto; }
.copyright { margin-top: 26px; font-size: 12px; opacity: .85; }

/* 開局 */
#scr-new { align-items: center; justify-content: center; background: url(../assets/img/bg_home.webp) center/cover; overflow-y: auto; }
.panel { background: rgba(255,250,240,.96); border: 3px solid var(--teal-deep); border-radius: var(--radius); box-shadow: var(--shadow); }
.new-panel { width: min(640px, calc(100% - 32px)); padding: 24px; margin: 16px auto; }
.new-head { display: flex; gap: 16px; align-items: flex-start; }
.new-head h2 { margin: 0 0 6px; font-family: var(--serif); }
.new-head p { margin: 4px 0; line-height: 1.7; color: var(--ink-soft); }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--brass); object-fit: cover; flex: none; }
.new-form { display: grid; gap: 14px; margin-top: 18px; }
.new-form label { display: grid; gap: 6px; font-weight: 500; flex: 1; }
.new-form input, .new-form select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 2px solid #c9bba3; background: #fff; }
.hint { margin: 0; padding: 10px 12px; background: #f3ead6; border-radius: 10px; font-size: 14px; color: var(--ink-soft); }

/* 主畫面 */
#scr-main { flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--teal-deep); color: #fff; font-weight: 500; flex-wrap: wrap; }
.topbar .date { font-family: var(--serif); font-size: 18px; }
.topbar small { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--brass); color: var(--teal-deep); font-size: 13px; }
.topbar .gold { color: var(--brass-light); }
.topbar .left { margin-left: auto; font-size: 13px; opacity: .8; }
.main-body { flex: 1; display: grid; grid-template-columns: 1.25fr 1fr; min-height: 0; }
.stage { position: relative; overflow: hidden; }
.stage-bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: background-image .4s; }
.girl { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 94%; max-width: 92%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.girl.scene { height: 72%; bottom: 14%; width: auto; max-width: 80%; border-radius: 18px; border: 4px solid var(--paper); }
.badges { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; box-shadow: var(--shadow); }
.badge.sick { background: var(--sky); } .badge.rebel { background: #333; } .badge.fat { background: #d08a3a; } .badge.love { background: var(--rose); } .badge.away { background: #777; }
.bond-meter { position: absolute; right: 12px; bottom: 12px; background: rgba(255,250,240,.92); padding: 6px 10px; border-radius: 12px; font-size: 12px; width: 150px; box-shadow: var(--shadow); }
.bond-meter .bar i { background: var(--rose); }
.side { display: flex; flex-direction: column; background: var(--paper); border-left: 3px solid var(--teal-deep); min-height: 0; }
.profile { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 10px 14px; font-size: 13px; border-bottom: 2px dashed #e0d2b8; }
.profile b { color: var(--teal); font-weight: 700; }
.profile .pname { grid-column: 1 / -1; font-family: var(--serif); font-size: 20px; color: var(--ink); }
.tabs { display: flex; padding: 8px 10px 0; gap: 4px; }
.tab { flex: 1; border: 2px solid var(--teal-deep); border-bottom: none; background: #efe4cd; padding: 6px 0; border-radius: 10px 10px 0 0; font-weight: 700; color: var(--ink-soft); }
.tab.active { background: var(--teal); color: #fff; }
.stats { flex: 1; overflow-y: auto; padding: 10px 14px; border-top: 2px solid var(--teal-deep); }
.stat { display: grid; grid-template-columns: 48px 1fr 44px; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.stat .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar { height: 10px; background: #e7dcc6; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #4fb3a9); border-radius: 999px; transition: width .4s; }
.stat.stress .bar i { background: linear-gradient(90deg, #e9a23b, var(--bad)); }
.stat.sin .bar i { background: linear-gradient(90deg, #8a6bb3, #4b2f6e); }
.stat-note { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.6; }
.cmdbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 8px; background: var(--teal-deep); }
.cmd { border: 2px solid var(--brass); background: var(--paper); border-radius: 12px; padding: 8px 4px; font-size: 15px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 3px 0 #8a6626; }
.cmd b { font-size: 22px; font-weight: 400; }
.cmd.primary { background: var(--brass-light); }
.cmd:active { transform: translateY(3px); box-shadow: none; }

/* 視窗 */
.modal { position: absolute; inset: 0; background: rgba(20,30,30,.55); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { width: min(760px, 100%); max-height: 92%; display: flex; flex-direction: column; background: var(--paper); border: 3px solid var(--teal-deep); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.modal-card header { display: flex; align-items: center; padding: 10px 16px; background: var(--teal); color: #fff; }
.modal-card h3 { margin: 0; font-family: var(--serif); font-size: 20px; flex: 1; }
.x { background: none; border: none; color: #fff; font-size: 22px; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card { text-align: left; border: 2px solid #d9c9aa; background: #fff; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.5; transition: border-color .15s, transform .1s; }
.card:hover:not(:disabled) { border-color: var(--teal); transform: translateY(-2px); }
.card:disabled { opacity: .5; cursor: not-allowed; }
.card h4 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--ink-soft); font-size: 13px; }
.card .up { color: var(--good); } .card .down { color: var(--bad); }
.card.sel { border-color: var(--brass); background: #fff6df; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.slot { border: 2px dashed var(--teal); border-radius: 12px; padding: 8px; text-align: center; min-height: 64px; background: #f6efe0; font-size: 14px; }
.slot.cur { border-style: solid; background: #fff; box-shadow: 0 0 0 3px var(--brass-light); }
.slot small { display: block; color: var(--ink-soft); }
.cat-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.cat-tabs .btn { padding: 6px 14px; font-size: 15px; }
.cat-tabs .btn.on { background: var(--teal); color: #fff; }
.sum { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; flex-wrap: wrap; }

/* 對話框 */
.dialog { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(900px, calc(100% - 24px)); display: flex; gap: 12px; padding: 14px; background: rgba(255,250,240,.97); border: 3px solid var(--teal-deep); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 40; cursor: pointer; }
.dialog[hidden] { display: none; }
#dlg-face { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; object-position: top; border: 2px solid var(--brass); flex: none; background: #eee; }
.dlg-body { flex: 1; min-width: 0; }
.dlg-name { font-weight: 700; color: var(--teal); margin-bottom: 4px; }
.dlg-text { font-size: 17px; line-height: 1.75; white-space: pre-line; }
.dlg-choices { display: grid; gap: 8px; margin-top: 10px; }
.dlg-choices .btn { text-align: left; border-radius: 10px; }
.dlg-next { text-align: right; color: var(--brass); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }

/* 行程執行 */
#scr-period { align-items: center; justify-content: center; }
.period-bg, .map-bg, .battle-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.period-bg::after, .map-bg::after, .battle-bg::after { content: ''; position: absolute; inset: 0; background: rgba(20,30,30,.35); }
.period-box { position: relative; width: min(720px, calc(100% - 32px)); background: rgba(255,250,240,.96); border: 3px solid var(--teal-deep); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-align: center; }
.period-head span { display: inline-block; padding: 2px 12px; background: var(--brass); border-radius: 999px; font-weight: 700; color: var(--teal-deep); }
.period-head h2 { font-family: var(--serif); margin: 8px 0 14px; font-size: 26px; }
.days { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.day { aspect-ratio: 1; border-radius: 10px; background: #e7dcc6; display: grid; place-items: center; font-size: 20px; font-weight: 700; opacity: .4; transform: scale(.8); transition: all .2s; }
.day.show { opacity: 1; transform: scale(1); }
.day.ok { background: #d6efdc; color: var(--good); }
.day.ng { background: #f6d6d1; color: var(--bad); }
.period-delta { margin: 14px 0; min-height: 40px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; background: #eee; }
.chip.up { background: #d6efdc; color: #22683a; } .chip.down { background: #f6d6d1; color: #9b2c22; }
.chip.money { background: #fbe9bf; color: #7a5410; }

/* 冒險地圖 */
#scr-map { align-items: center; justify-content: center; }
.map-wrap { position: relative; display: grid; grid-template-columns: 240px auto 160px; gap: 16px; align-items: center; padding: 16px; }
.map-info { background: rgba(255,250,240,.95); border: 3px solid var(--teal-deep); border-radius: var(--radius); padding: 12px; font-size: 14px; }
.map-info h2 { margin: 0 0 8px; font-family: var(--serif); }
.legend { font-size: 12px; color: var(--ink-soft); }
.hpmp { display: grid; gap: 4px; }
.bar.hp i { background: linear-gradient(90deg, #e2564a, #f08a5d); }
.bar.mp i { background: linear-gradient(90deg, #4c74c6, #6fa8e8); }
.map-grid { display: grid; gap: 2px; background: rgba(0,0,0,.35); padding: 6px; border-radius: 12px; border: 3px solid var(--brass); }
.cell { width: clamp(24px, 4.4vw, 46px); aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: clamp(14px, 2.2vw, 24px); }
.cell.fog { background: #4a3b2c; }
.cell.wall { background: #2a3a2f; box-shadow: inset 0 0 0 2px rgba(0,0,0,.2); }
.cell.path { background: rgba(250,240,215,.85); }
.cell.me { background-color: var(--brass-light); background-size: 260%; background-position: 50% 6%; background-repeat: no-repeat; box-shadow: 0 0 0 3px var(--rose) inset; }
.dpad { display: grid; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); gap: 4px; }
.dpad button { border: 2px solid var(--teal-deep); background: var(--paper); border-radius: 12px; font-size: 20px; box-shadow: 0 3px 0 var(--teal-deep); }
.dpad button:active { transform: translateY(3px); box-shadow: none; }
.dpad [data-dir="0,-1"] { grid-column: 2; grid-row: 1; }
.dpad [data-dir="-1,0"] { grid-column: 1; grid-row: 2; }
.dpad [data-dir="1,0"] { grid-column: 3; grid-row: 2; }
.dpad [data-dir="0,1"] { grid-column: 2; grid-row: 3; }

/* 戰鬥 */
#scr-battle { align-items: stretch; justify-content: center; }
.battle-wrap { position: relative; width: min(900px, 100%); display: grid; grid-template-rows: 1fr auto auto; padding: 16px; gap: 10px; }
.foe { text-align: center; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.foe-name { font-family: var(--serif); font-size: 22px; color: #fff; text-shadow: 0 2px 6px #000; }
.foe .bar { width: 260px; margin: 6px 0; }
#b-img { max-height: 36vh; max-width: 60%; object-fit: contain; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.95) 55%, rgba(255,255,255,0) 72%); }
#b-img.hit { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.battle-log { background: rgba(255,250,240,.95); border: 3px solid var(--teal-deep); border-radius: var(--radius); padding: 10px 14px; height: 120px; overflow-y: auto; font-size: 15px; line-height: 1.7; }
.me { display: grid; grid-template-columns: 90px 1fr; gap: 10px; background: rgba(255,250,240,.95); border: 3px solid var(--teal-deep); border-radius: var(--radius); padding: 10px; align-items: center; }
#b-girl { width: 90px; height: 90px; object-fit: cover; object-position: top; border-radius: 12px; border: 2px solid var(--brass); }
.me-bars { display: grid; gap: 3px; font-size: 14px; }
.b-cmds { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.b-cmds .btn { padding: 10px 4px; font-size: 15px; border-radius: 12px; }

/* 結局 */
#scr-ending { flex-direction: column; background: #111; overflow-y: auto; }
.ending-img { flex: none; height: 52vh; background-size: cover; background-position: center 15%; }
.ending-box { position: relative; margin: -60px auto 24px; width: min(760px, calc(100% - 32px)); background: var(--paper); border: 3px solid var(--brass); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.e-sub { margin: 0; color: var(--teal); font-weight: 700; }
.ending-box h1 { font-family: var(--serif); margin: 4px 0 12px; font-size: clamp(26px, 5vw, 40px); }
.e-text { line-height: 1.9; font-size: 17px; }
.e-review { background: #f3ead6; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.8; margin: 14px 0; }
.grade { font-family: var(--serif); font-size: 48px; color: var(--brass); float: right; line-height: 1; margin-left: 12px; }

/* 圖鑑 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.g-item { border-radius: 12px; overflow: hidden; border: 2px solid #d9c9aa; background: #fff; font-size: 13px; text-align: center; }
.g-item .pic { aspect-ratio: 16/9; background-size: cover; background-position: center; }
.g-item.locked .pic { filter: brightness(0) opacity(.25); }
.g-item p { margin: 6px; }

.toast { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: var(--teal-deep); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; box-shadow: var(--shadow); font-weight: 500; max-width: calc(100% - 32px); text-align: center; }
.toast[hidden] { display: none; }
.help h4 { margin: 14px 0 4px; color: var(--teal); }
.help p, .help li { line-height: 1.75; font-size: 15px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mini td, table.mini th { border-bottom: 1px solid #e3d6bd; padding: 6px 4px; text-align: left; }

/* 收藏卡冊 */
.cardbook { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tcard { position: relative; padding: 0; border: 3px solid #cfc2a6; background: #fff; border-radius: 12px; overflow: hidden; font-size: 13px; text-align: center; transition: transform .1s; }
.tcard:hover:not(:disabled) { transform: translateY(-3px); }
.tcard .pic { aspect-ratio: 1; background-size: cover; background-position: center top; }
.tcard .pic.icon { display: flex; align-items: center; justify-content: center; font-size: 44px; background: linear-gradient(135deg, #f6efe0, #e6f1ef); }
.tcard p { margin: 6px 4px; line-height: 1.35; min-height: 2.7em; }
.tcard .rar { position: absolute; top: 4px; left: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; background: #8b8172; }
.tcard.r-R { border-color: var(--sky); } .tcard.r-R .rar { background: var(--sky); }
.tcard.r-SR { border-color: #9a5cc6; } .tcard.r-SR .rar { background: #9a5cc6; }
.tcard.r-SSR { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass-light); } .tcard.r-SSR .rar { background: var(--brass); }
.tcard.locked { opacity: 1; cursor: default; }
.tcard.locked .pic { filter: brightness(0) opacity(.2); }
.card-desc { white-space: pre-line; background: #f3ead6; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.new-dot { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--rose); color: #fff; font-size: 12px; vertical-align: 2px; }
.title-menu .sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.title-menu .sub .sync-btn { grid-column: auto; }
.sync-code { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .12em; color: var(--teal-deep); background: #fff6df; padding: 2px 10px; border-radius: 8px; border: 2px dashed var(--brass); }
.sync-input { font-size: 18px; padding: 8px 12px; border: 2px solid var(--teal-deep); border-radius: 10px; width: 12em; max-width: 100%; text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, Consolas, monospace; }

/* v1.3.0：限定卡、閃卡、每週挑戰、孟公日記、分享圖 */
#scr-title { overflow-y: auto; align-items: flex-start; }
.title-box { margin: auto; }
.title-events { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.title-events .weekly-btn, .title-events.n1 .season-btn { grid-column: 1 / -1; }
.title-events:empty { display: none; }
.title-events .btn { font-size: 15px; padding: 8px 10px; }
.season-btn { background: linear-gradient(135deg, #fff1d6, #ffe0e0); border-color: var(--rose); }
.weekly-btn { background: #eef6f4; }
.weekly-now { background: #fff6df; border: 2px dashed var(--brass); border-radius: 10px; padding: 10px 12px; }
.weekly-list li { margin: 4px 0; }
.tcard .open { display: block; margin: -2px 4px 6px; font-size: 11px; color: var(--rose); line-height: 1.3; }
.tcard.shiny { border-color: #e2b400; box-shadow: 0 0 0 2px #ffe680, 0 0 14px rgba(255, 200, 40, .55); }
.tcard.shiny .rar { background: linear-gradient(90deg, #e2b400, #ff7ac8, #5ac8ff); }
.tcard.shiny .pic { position: relative; }
.tcard.shiny .pic::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .75) 45%, rgba(255, 230, 120, .5) 50%, transparent 65%); background-size: 250% 100%; animation: shine 2.4s linear infinite; mix-blend-mode: screen; }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .tcard.shiny .pic::after { animation: none; } }
.diary-list { padding-left: 1.6em; margin: 8px 0; }
.diary-list li { margin: 8px 0; padding: 8px 10px; background: #fffaf0; border-left: 4px solid var(--brass); border-radius: 6px; line-height: 1.6; }
.diary-list li.locked { color: #9b9184; background: #f3ead6; border-left-color: #cfc2a6; }
.diary-list li small { margin-left: 6px; }
.share-prev { display: block; width: 100%; max-width: 420px; max-height: 62vh; object-fit: contain; margin: 0 auto; border-radius: 10px; box-shadow: var(--shadow); }
.ending-box .row2 { flex-wrap: wrap; }

/* 手機版 */
@media (max-width: 820px) {
  .main-body { grid-template-columns: 1fr; grid-template-rows: 42% 58%; }
  .side { border-left: none; border-top: 3px solid var(--teal-deep); }
  .topbar { gap: 8px 12px; font-size: 14px; padding: 6px 12px; }
  .topbar .date { font-size: 15px; }
  .topbar .left { display: none; }
  .cmdbar { grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 6px; }
  .cmd { font-size: 12px; padding: 6px 2px; } .cmd b { font-size: 18px; }
  .bond-meter { width: 120px; }
  .map-wrap { grid-template-columns: 1fr; justify-items: center; gap: 8px; padding: 8px; }
  .cell { width: clamp(14px, calc((100vw - 64px) / 17), 40px); font-size: 12px; border-radius: 4px; }
  .map-grid { gap: 1px; padding: 4px; }
  .map-info { width: 100%; padding: 8px; } .map-info h2 { font-size: 18px; margin: 0; } .legend { display: none; }
  .dpad { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 40px); }
  .days { grid-template-columns: repeat(5, 1fr); }
  .b-cmds { grid-template-columns: repeat(3, 1fr); }
  .dialog { bottom: 8px; padding: 10px; } #dlg-face { width: 60px; height: 60px; } .dlg-text { font-size: 15px; }
  .slots { gap: 4px; } .slot { font-size: 12px; padding: 6px 4px; }
  .dialog { max-height: 72%; overflow-y: auto; }
  .cardbook { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .tcard .pic.icon { font-size: 34px; }
}

/* AWD：依裝置類型分段調整 */
/* 小螢幕手機（≤400px） */
@media (max-width: 400px) {
  .season-btn .new-dot { display: none; }
  .title-menu .sub .btn { font-size: 14px; padding-left: 6px; padding-right: 6px; }
  .title-events .btn { font-size: 14px; padding: 8px 6px; }
  .title-box { padding: 16px; }
  .title-menu { gap: 8px; }
  .btn.big { padding: 9px 14px; font-size: 15px; }
  .cmd { font-size: 11px; }
  .modal { padding: 8px; }
  .modal-body { padding: 10px; }
  .dlg-choices .btn { padding: 8px 12px; font-size: 15px; }
}
/* 平板直向／小筆電（821～1100px） */
@media (min-width: 821px) and (max-width: 1100px) {
  .cmd { font-size: 14px; }
  .cardbook { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
/* 手機橫向（高度很矮） */
@media (max-height: 500px) and (orientation: landscape) {
  .main-body { grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .side { border-top: none; border-left: 3px solid var(--teal-deep); }
  .title-gear { display: none; }
  .logo { font-size: 40px; margin: 0; }
  .tagline { margin: 4px 0 8px; }
  .title-menu { grid-template-columns: 1fr 1fr; max-width: 560px; gap: 8px; }
  .title-menu .sub { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
  .title-menu .sub .btn { padding: 6px 8px; font-size: 14px; }
  .title-events { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .title-menu .sub .sync-btn { grid-column: auto; }
  #daily-btn { grid-column: 1 / -1; }
  .btn.big { padding: 8px 12px; font-size: 15px; }
  .dialog { max-height: 86%; overflow-y: auto; bottom: 6px; }
  #dlg-face { width: 52px; height: 52px; }
  .ending-img { height: 70vh; }
  .cmd { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 4px; font-size: 14px; }
  .cmd b { font-size: 16px; }
}

/* 對話進行中：鎖住其他操作 */
#app.busy > *:not(#dialog):not(#toast) { pointer-events: none; }

/* Netlify 標章留空 */
body.on-netlify #app { height: calc(100vh - 56px); height: calc(100dvh - 56px); }

/* v1.4.0 背景音樂 */
.bgm-btn { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--brass-light); background: rgba(31, 59, 58, .6); color: #fff; font-size: 20px; line-height: 1; }
.bgm-btn:active { transform: scale(.94); }
.bgm-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.bgm-vol { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.bgm-vol input { width: 160px; max-width: 46vw; accent-color: var(--teal); }
.bgm-list { display: grid; gap: 8px; }
.bgm-item { text-align: left; border: 2px solid #e0d3b8; background: var(--paper); border-radius: 12px; padding: 10px 12px; color: var(--ink); }
.bgm-item b { display: block; font-size: 15px; }
.bgm-item small { color: var(--ink-soft); }
.bgm-item.on { border-color: var(--teal); background: #e7f2ef; box-shadow: 0 0 0 2px rgba(44, 110, 106, .18); }
.bgm-now { font-style: normal; color: var(--teal); animation: bgm-pulse 1.2s ease-in-out infinite; }
@keyframes bgm-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .bgm-now { animation: none; } }
