:root {
  --pick: #d9743a;
  --pick-soft: #fff0df;
  --ink: #4d4037;
  --ink-soft: #6b5c50;
  --paper: #fffdf6;
  --cream: #fbf3e0;
  --line: #eadfc8;
  --orange: #f08a57;
  --orange-deep: #d96f3e;
  --brand: #bd542b;
  --brand-shadow: #913c21;
  --brand-hover: #a94a25;
  --green: #4fa871;
  --green-soft: #e4f5e4;
  --red: #cf3f36;
  --red-soft: #fde8e4;
  --sky: #a9ddf5;
  --shadow: 0 8px 26px rgba(90, 70, 50, .2);
  --font: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans CJK TC', sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  pointer-events: none;
}
#stage > * { pointer-events: auto; }
#stage > #toasts, #stage > #controls { pointer-events: none; }
#controls > * { pointer-events: auto; }

#legal {
  position: relative;
  flex: none;
  padding: 3px 12px calc(3px + env(safe-area-inset-bottom));
  background: #fbf6e8;
  color: #6b5c50;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}
.legal-short { display: none; }
@media (max-width: 760px), (max-height: 520px) {
  .legal-full { display: none; }
  .legal-short { display: inline; }
}
@media (max-width: 760px) {
  #legal { padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); font-size: 11px; line-height: 1.45; }
  .legal-short > span { display: block; }
}

button { font-family: inherit; color: inherit; }

.btn {
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.btn:hover:not(:disabled) { background: var(--cream); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .62; cursor: default; }
.btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 0 var(--brand-shadow);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-primary:disabled { opacity: 1; background: #e6dccb; border-color: #e6dccb; color: #6b5c50; box-shadow: none; }
.btn-big { font-size: 19px; min-height: 56px; }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-sos { background: var(--red); border-color: #a92f28; box-shadow: 0 4px 0 #a92f28; }
.btn-sos:hover:not(:disabled) { background: #bb352d; }
:focus-visible { outline: 3px solid #4f8fd1; outline-offset: 2px; }
#card:focus { outline: none; }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn.is-on { color: var(--brand); border-color: var(--orange); }

/* HUD ------------------------------------------------------------ */
#hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.hud-route, .hud-risk {
  background: rgba(255, 253, 246, .93);
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(90, 70, 50, .15);
}
.hud-route { flex: 1 1 56%; min-width: 0; padding: 7px 14px 11px; }
.hud-route-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; white-space: nowrap; }
.hud-route-top strong { font-size: 15px; }
.hud-route-top span { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.route-bar { position: relative; height: 9px; margin-top: 4px; border-radius: 6px; background: #eadfc8; }
.route-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #8fd0a0, #5fa781); }
.route-tick { position: absolute; top: -2px; width: 2px; height: 13px; background: rgba(120, 100, 80, .42); }
.route-dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.hud-risk {
  flex: 1 1 40%;
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 2px solid transparent;
}
.risk-body { flex: 1; min-width: 0; }
.risk-top { font-size: 14px; line-height: 1.25; color: var(--ink); white-space: nowrap; }
.risk-top b { font-size: 18px; font-variant-numeric: tabular-nums; }
.risk-track { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.risk-scale { flex: none; font-size: 12px; line-height: 1; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.risk-bar { position: relative; flex: 1; min-width: 0; height: 14px; border-radius: 7px; background: #eadfc8; overflow: hidden; }
.risk-bar::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: rgba(90, 70, 50, .32); }
.risk-fill { height: 100%; width: 0; border-radius: 7px; }
.hud-btns { display: flex; gap: 8px; flex: none; }

/* 風險過半：警示色邊，每隔幾秒輕晃一下，不持續干擾 */
.hud-risk.is-warn {
  border-color: var(--red);
  background: #fff4ef;
  box-shadow: 0 0 0 3px rgba(207, 63, 54, .18), 0 3px 12px rgba(90, 70, 50, .15);
  animation: risk-wobble 4.2s ease-in-out infinite;
}
.hud-risk.is-warn .risk-top b { color: #b5322a; }
.hud-risk.bump { animation: bump .5s ease; }
#hud-stage.flash { animation: stage-flash 1.3s ease; }

@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(207, 63, 54, .4); }
  100% { transform: scale(1); }
}
@keyframes risk-wobble {
  0%, 82%, 100% { transform: none; }
  85% { transform: translateX(-1.5px) rotate(-.5deg); }
  88% { transform: translateX(1.5px) rotate(.5deg); }
  91% { transform: translateX(-1px) rotate(-.3deg); }
  94% { transform: translateX(1px) rotate(.3deg); }
}
@keyframes stage-flash { 20%, 60% { color: var(--brand); } }

/* 桌機空間夠，風險條再放大一點 */
@media (min-width: 761px) and (min-height: 521px) {
  .hud-risk { padding: 5px 14px; }
  #risk-face { width: 40px; height: 40px; flex: none; }
  .risk-top { font-size: 15px; }
  .risk-top b { font-size: 22px; }
  .risk-bar { height: 16px; }
  .risk-scale { font-size: 13px; }
}

/* 提示與 toast ---------------------------------------------------- */
#toasts {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 8;
}
.toast {
  padding: 7px 18px;
  border-radius: 999px;
  background: rgba(255, 253, 246, .96);
  box-shadow: 0 3px 12px rgba(90, 70, 50, .2);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  animation: toast-in .24s ease;
  transition: opacity .35s ease;
}
.toast.out { opacity: 0; }
.toast.good { color: #237a45; }
.toast.warn { color: #b0491f; }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } }

#prompt {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  z-index: 4;
  max-width: 90%;
  min-height: 44px;
  padding: 8px 20px;
  border: 2px solid var(--orange);
  border-radius: 999px;
  background: var(--paper);
  color: var(--brand);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(90, 70, 50, .2);
  animation: glow 1.1s ease-in-out 2;
}
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(240, 138, 87, .35); } }

/* 操作區 --------------------------------------------------------- */
#controls { position: absolute; inset: 0; }

#joy {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 124px;
  height: 124px;
  border: 3px solid rgba(255, 253, 246, .85);
  border-radius: 50%;
  background: rgba(255, 253, 246, .34);
  touch-action: none;
  display: none;
  place-items: center;
}
#joy-knob {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 253, 246, .96);
  box-shadow: 0 3px 8px rgba(90, 70, 50, .3);
}

#btn-interact {
  position: absolute;
  right: 18px;
  bottom: 24px;
  width: 84px;
  height: 84px;
  border: 3px solid rgba(255, 253, 246, .9);
  border-radius: 50%;
  background: rgba(190, 180, 165, .78);
  color: #fff;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 800;
  cursor: pointer;
  display: none;
  place-items: center;
  padding: 0;
  touch-action: manipulation;
}
#btn-interact.is-ready { background: var(--brand); animation: glow 1.1s ease-in-out 2; padding: 0 16px; }

#actions {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.act-btn {
  min-height: 38px;
  padding: 4px 12px 4px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 253, 246, .88);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.act-toggle { display: none; }
.act-btn kbd {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--cream);
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
}
#hints {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 2px 14px;
  border-radius: 999px;
  background: #fbf3e0;
  color: #4d4037;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}

body.touch #joy, body.touch #btn-interact { display: grid; }
body.touch #hints { display: none; }
body.touch .act-btn { padding: 4px 14px; min-height: 40px; }
body.touch .act-btn kbd { display: none; }

@media (max-width: 760px) {
  #joy, #btn-interact { display: grid; }
  #hints { display: none; }
  /* 小動作收在右側主鈕上方，不擋搖桿與角色前方 */
  #actions { left: auto; right: 18px; bottom: 120px; transform: none; flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
  .act-toggle {
    display: block;
    min-height: 44px;
    padding: 4px 14px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 253, 246, .92);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
  }
  #actions:not(.open) .act-btn { display: none; }
  .act-btn { padding: 4px 14px; min-height: 44px; }
  .act-btn kbd { display: none; }
  #prompt { bottom: 156px; font-size: 14px; }
  /* 兩列：路線進度／風險＋功能鍵，總高 104–112px */
  #hud { flex-wrap: wrap; gap: 6px 8px; left: 8px; right: 8px; top: calc(6px + env(safe-area-inset-top)); }
  .hud-route { flex: 1 1 100%; padding: 5px 12px 11px; }
  .hud-route-top strong { font-size: 15px; line-height: 1.4; }
  .route-bar { margin-top: 3px; }
  .hud-risk { flex: 1 1 0; padding: 5px 10px; }
  #risk-face { width: 30px; height: 30px; flex: none; }
}
/* 小手機仍保留動作選單，拍照也從這裡進入。 */
@media (max-width: 760px) and (max-height: 640px) and (orientation: portrait) {
  #prompt { bottom: 148px; }
  /* 螢幕太矮放不下兩個：走到題目前先留互動提示，動作選單讓位 */
  #app:has(#prompt:not([hidden])) #actions { display: none; }
}

/* 事件卡片 ------------------------------------------------------- */
.card {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: min(640px, calc(100% - 20px));
  max-height: calc(100% - 92px - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  transform: translateX(var(--card-x, -50%));
  z-index: 5;
  border: 3px solid #fff;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: card-in .28s cubic-bezier(.2, 1.3, .5, 1);
}
.card.is-right { border-color: #9fdcb0; }
.card.is-wrong { border-color: #f4a79f; }
.card.shake { animation: card-shake .18s ease; }

@keyframes card-in { from { transform: translateX(var(--card-x, -50%)) translateY(30px) scale(.97); opacity: 0; } }
@keyframes card-shake {
  25% { transform: translateX(calc(var(--card-x, -50%) - 3px)); }
  75% { transform: translateX(calc(var(--card-x, -50%) + 3px)); }
  100% { transform: translateX(var(--card-x, -50%)); }
}

.card-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 16px 18px 22px;
  scroll-padding-bottom: 22px;
}
/* 捲動清單下面還有內容：底部淡出，不讓半張卡被硬切 */
#card-scroll.has-more, #prep-body.has-more, #gear-scroll.has-more, .gear-left.has-more, .ending-scroll.has-more, .ending-left.has-more, .ending-right.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), rgba(0, 0, 0, .12));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), rgba(0, 0, 0, .12));
}
/* 題卡固定區：桌機與橫式題名就在左欄，不用這一行 */
.card-fixed { display: contents; }
.card-fixed-title { display: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag {
  display: inline-block;
  padding: 2px 11px;
  border-radius: 999px;
  background: #e2f2ea;
  color: #2f6e50;
  font-size: 13px;
  font-weight: 700;
}
.card-count { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.card h2 { margin: 7px 0 3px; font-size: 24px; line-height: 1.35; font-weight: 700; }
#card-sit { margin: 0 0 11px; font-size: 17px; line-height: 1.6; }

.opts { display: grid; gap: 8px; }
.opt {
  min-height: 52px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px 8px 9px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: #fff;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .14s ease, border-color .14s ease;
}
@media (hover: hover) { .opt:hover:not(:disabled) { background: #fff5e6; border-color: var(--orange); } }
.opt:disabled { cursor: default; color: var(--ink); }
.opt-key {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 800;
}
.answered .opt:not(.correct):not(.wrong) { opacity: .62; }
.opt.correct { border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.opt.correct .opt-key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .opt-key { background: var(--red); color: #fff; }

.fb { margin-top: 11px; padding: 11px 14px; border-radius: 15px; background: var(--cream); }
.is-right .fb { background: var(--green-soft); }
.is-wrong .fb { background: var(--red-soft); }
.fb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 17px; }
.fb-gain { color: #1f7040; font-weight: 700; }
.fb-loss { color: #b5322a; font-weight: 700; }
#fb-why { margin: 4px 0 0; font-size: 16px; line-height: 1.6; }
.fb-src { margin: 5px 0 0; font-size: 13px; color: #6b5c50; }
.fb-src:empty { display: none; }

.card-foot { flex: none; padding: 10px 18px 15px; border-top: 2px solid var(--cream); }
.card-foot .btn { width: 100%; }

/* 直式：底部面板，內容內捲、繼續鈕固定 */
@media (max-width: 900px) and (orientation: portrait) {
  .card {
    bottom: 8px;
    width: calc(100% - 16px);
    max-height: min(56vh, calc(100% - 134px));
    max-height: min(56dvh, calc(100% - 134px));
    border-radius: 20px;
  }
  .card.answered {
    max-height: min(68vh, calc(100% - 134px));
    max-height: min(68dvh, calc(100% - 134px));
  }
  .card-scroll { padding: 10px 14px 20px; }
  /* 徽章與題名固定在捲動區外，總高不超過 56px；題名不再於捲動區重複 */
  .card-fixed {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    max-height: 56px;
    padding: 4px 12px;
    border-radius: 17px 17px 0 0;
    background: var(--cream);
  }
  .card.is-key .card-fixed { background: linear-gradient(90deg, #ffe3d3, #fff2e4); }
  .card-fixed .key-strip { padding: 0; border-radius: 0; background: none; flex: 0 1 auto; min-width: 0; }
  .card-fixed-title {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    text-align: right;
    cursor: pointer;
    touch-action: manipulation;
  }
  .card:not(.is-key) .card-fixed-title { justify-content: flex-start; text-align: left; font-size: 18px; }
  .card.answered .card-fixed-title::after { content: '↑ 回看'; flex: none; color: var(--brand); font-size: 13px; }
  .card h2 { display: none; }
  .card-head { margin-bottom: 6px; }
  #card-sit { font-size: 16px; }
  .card-foot { padding: 8px 14px 12px; }
}
@media (max-height: 700px) and (orientation: portrait) {
  /* 短螢幕：答題後少放大一點，把位置留給縮小後的角色 */
  .card.answered {
    max-height: min(60vh, calc(100% - 134px));
    max-height: min(60dvh, calc(100% - 134px));
  }
  .opt { min-height: 48px; padding: 6px 11px 6px 8px; }
  .opts { gap: 6px; }
  #card-sit { margin-bottom: 8px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .card { width: min(880px, calc(100% - 16px)); bottom: 4px; max-height: calc(100% - 62px); border-radius: 18px; }
  .card-scroll { display: grid; grid-template-columns: 2fr 3fr; gap: 14px; padding: 10px 14px; }
  .card-main { position: sticky; top: 0; align-self: start; }
  .card h2 { font-size: 22px; line-height: 1.3; }
  #card-sit { font-size: 16px; line-height: 1.5; margin-bottom: 0; }
  .opt { min-height: 48px; font-size: 16px; line-height: 1.4; padding: 4px 10px 4px 7px; }
  .opts { gap: 6px; }
  .card-foot { padding: 6px 14px 8px; }
  #hud { top: 4px; left: 8px; right: 8px; }
  .hud-route { padding: 2px 12px 7px; }
  .hud-route-top strong { font-size: 14px; }
  .route-bar { margin-top: 2px; }
  .hud-risk { padding: 2px 10px; }
  .risk-body { display: flex; align-items: center; gap: 8px; }
  .risk-top { flex: none; font-size: 13px; }
  .risk-top b { font-size: 15px; }
  .risk-track { flex: 1; margin-top: 0; }
  .risk-bar { height: 12px; }
  #risk-face { width: 26px; height: 26px; flex: none; }
  #joy { width: 104px; height: 104px; bottom: 8px; left: 12px; }
  #joy-knob { width: 46px; height: 46px; }
  #btn-interact { width: 70px; height: 70px; bottom: 10px; }
  #actions { bottom: 14px; }
  /* 橫式的角色站得低，提示移到天空，不蓋住角色 */
  #prompt { top: 58px; bottom: auto; min-height: 40px; padding: 5px 18px; }
}
/* 橫式夠寬時卡片靠右，把左邊留給角色，不再互相蓋住 */
@media (max-height: 520px) and (orientation: landscape) and (min-width: 720px) {
  .card { --card-x: 0; left: auto; right: 8px; width: min(880px, calc(100% - 184px)); }
}
/* 桌機與平板橫式：卡片是右側面板，左邊留給角色與路標（直式平板仍用底部面板） */
@media (min-width: 761px) and (min-height: 521px) and (orientation: landscape), (min-width: 901px) and (min-height: 521px) {
  .card { --card-x: 0; left: auto; right: 16px; width: clamp(380px, 34vw, 480px); }
}

/* 開始畫面 ------------------------------------------------------- */
.screen { position: absolute; inset: 0; z-index: 6; pointer-events: none !important; }
.screen > * { pointer-events: auto; }

#start-screen { display: flex; align-items: center; padding: 20px 20px 20px clamp(16px, 4vw, 64px); }
.start-card {
  position: relative;
  width: min(400px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  border: 3px solid #fff;
  border-radius: 28px;
  background: rgba(255, 253, 246, .95);
  box-shadow: var(--shadow);
}
.start-kicker { margin: 0; padding-right: 104px; color: var(--brand); font-size: 14px; font-weight: 700; }
.start-card h1 { margin: 0; padding-right: 104px; font-size: clamp(38px, 7vw, 52px); line-height: 1.2; letter-spacing: .06em; color: #3f6f58; }
.start-sub { margin: 6px 0 16px; font-size: 16px; }
.start-btns { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.start-btns .btn-primary { grid-column: 1 / -1; }
.start-btns .btn:not(.btn-primary) { padding: 6px 4px; min-height: 44px; font-size: 14px; white-space: nowrap; }
.start-sound { position: absolute; top: 14px; right: 14px; }
/* 角落的小字連結，排在音效鈕左邊：點得到但不搶戲 */
.start-about {
  position: absolute;
  top: 24px;
  right: 60px;
  min-width: 40px;
  height: 24px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #8a7b6e;
  font-size: 12px;
  line-height: 24px;
  cursor: pointer;
  touch-action: manipulation;
}
.start-about:hover { color: var(--brand); text-decoration: underline; }

.load-notice { margin-top: 12px; padding: 11px 13px; border-radius: 14px; background: #fff1dc; font-size: 14.5px; }
.load-notice p { margin: 0 0 8px; }

@media (max-width: 760px) and (orientation: portrait) {
  #start-screen { align-items: flex-start; padding: calc(12px + env(safe-area-inset-top)) 12px 12px; }
  .start-card { width: 100%; padding: 20px; border-radius: 24px; }
  .start-card h1 { font-size: 38px; }
  .start-sub { margin: 4px 0 14px; }
  .start-btns .btn-primary { min-height: 54px; font-size: 18px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #start-screen { padding: 8px 8px 8px 16px; }
  .start-card { width: 340px; padding: 14px 20px; border-radius: 22px; }
  .start-card h1 { font-size: 30px; }
  .start-kicker { display: none; }
  .start-sub { font-size: 14px; line-height: 1.5; margin: 2px 0 8px; }
  .start-btns { gap: 8px; }
  .start-btns .btn-primary { min-height: 50px; padding: 4px 12px; font-size: 17px; }
  .start-sound { top: 10px; right: 10px; }
  .start-about { top: 20px; right: 56px; }
}

/* 結局畫面 ------------------------------------------------------- */
#ending-screen[data-tier='bad'] { background: rgba(255, 233, 206, .8); }
#ending-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(70, 70, 66, .45);
  pointer-events: auto !important;
}
.ending-panel {
  width: min(1040px, 100%);
  height: min(680px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-rows: minmax(0, 1fr) auto;
  border: 3px solid #fff;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ending-scroll { display: contents; }
.ending-left { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; padding: 18px 22px 6px; overflow-y: auto; min-height: 0; }
#ending-art { flex: none; width: 100%; height: clamp(180px, 34vh, 250px); border-radius: 18px; display: block; }
.ending-kicker { margin: 12px 0 0; color: var(--brand); font-size: 14px; font-weight: 700; }
.ending-left h2 { margin: 0; font-size: 28px; line-height: 1.3; }
#ending-msg { margin: 4px 0 12px; font-size: 16px; }
.ending-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ending-stats > div { padding: 6px 4px; border-radius: 13px; background: var(--cream); text-align: center; }
.ending-stats span { display: block; color: var(--ink-soft); font-size: 13px; }
.ending-stats b { font-size: 24px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.ending-best { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; }
.ending-best:empty { display: none; }
.ending-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ending-badges:empty { display: none; }
.badge-chip { padding: 3px 12px; border-radius: 999px; background: #fff0c9; color: #7f5512; font-size: 14px; font-weight: 700; }
.ending-btns { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: 2fr 1fr; gap: 10px; padding: 10px 22px 16px; background: var(--paper); }
.ending-credit { grid-column: 1 / -1; margin: -4px 0 -8px; font-size: 11.5px; line-height: 1.5; text-align: center; }
.ending-credit a { color: #9a8c7e; text-decoration: none; }
.ending-credit a:hover { color: var(--brand); text-decoration: underline; }

.ending-right { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; min-height: 0; padding: 18px 20px 30px; scroll-padding-bottom: 30px; background: #fbf7ea; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.ending-right h3 { margin: 0; font-size: 21px; }
.summary-note { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; }
#summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sum-item { border: 2px solid var(--line); border-radius: 15px; background: #fff; }
.sum-item.ok { border-color: #cdebd5; }
.sum-item.ng { border-color: #f5c4bd; }
.sum-item summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 12px;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
}
.sum-item summary::-webkit-details-marker { display: none; }
.sum-item summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin: -3px 3px 0 2px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg);
}
.sum-item details[open] summary::after { margin-top: 3px; transform: rotate(-135deg); }
.sum-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; line-height: 1.4; }
.sum-res { flex: none; font-size: 14px; font-weight: 700; }
.sum-res.ok { color: #237a45; }
.sum-res.ng { color: #b5322a; }
.sum-body { padding: 0 13px 11px; }
.sum-key { margin: 0 0 6px; padding: 6px 10px; border-left: 4px solid var(--orange); border-radius: 4px 10px 10px 4px; background: #fff5e6; font-size: 16px; font-weight: 600; line-height: 1.5; }
.ok .sum-key { border-left-color: var(--green); background: var(--green-soft); }
.sum-sit { margin: 0 0 4px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.sum-item dl { margin: 0; font-size: 15px; line-height: 1.5; }
.sum-item dt { margin-top: 4px; color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.sum-item dd { margin: 0; }
.c-ok { color: #1f7040; font-weight: 600; }
.c-ng { color: #b5322a; font-weight: 600; }
.sum-src { margin: 5px 0 0; color: #6b5c50; font-size: 13px; }

/* 直式手機：內容一起捲，再玩一次／分享固定在面板底部 */
@media (max-width: 760px) {
  #ending-screen { padding: 0; }
  .ending-panel { display: flex; flex-direction: column; width: 100%; height: 100%; border: 0; border-radius: 0; }
  .ending-scroll { display: block; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scroll-padding-bottom: 30px; }
  .ending-left, .ending-right { overflow: visible; }
  .ending-left { padding: 12px 14px; }
  .ending-right { padding: 14px 14px 30px; }
  #ending-art { height: clamp(170px, 27vh, 230px); }
  .ending-btns { flex: none; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 2px solid var(--cream); }
}
/* 直式手機結局：先講這趟該改什麼，照片和數字排在後面 */
@media (max-width: 760px) and (orientation: portrait) {
  .ending-scroll { display: flex; flex-direction: column; padding: 12px 14px 30px; }
  .ending-scroll > * { display: contents; }
  .ending-scroll > * > * { flex: none; order: 20; }
  #ending-art { order: 1; height: clamp(150px, 24vh, 210px); }
  .ending-btns .btn { white-space: nowrap; }
  .ending-kicker { order: 2; }
  #ending-title { order: 3; font-size: 25px; }
  #ending-trip { order: 4; }
  #ending-safety { order: 5; }
  #ending-msg { order: 6; margin-bottom: 10px; }
  #ending-review { order: 7; }
  .ending-stats { order: 8; margin-bottom: 8px; }
  .ending-badges { order: 9; margin: 0 0 8px; }
  .ending-best { order: 10; margin: 0 0 10px; }
  #ending-photos { order: 11; }
}
/* 橫式手機：維持左右兩欄，插畫與成績一眼可見 */
@media (max-height: 520px) and (min-width: 761px) {
  #ending-screen { padding: 0; }
  .ending-panel { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .ending-left { padding: 8px 14px 2px; }
  #ending-art { height: 112px; }
  .ending-kicker { margin-top: 4px; font-size: 13px; }
  .ending-left h2 { order: 1; font-size: 21px; }
  /* 成績與徽章排在說明文字前，不用捲動就看得到 */
  .ending-stats { order: 2; margin-top: 4px; }
  .ending-stats > div { padding: 2px 4px; }
  .ending-stats span { line-height: 1.3; white-space: nowrap; }
  .ending-stats b { display: block; font-size: 19px; line-height: 1.2; }
  .ending-badges { order: 3; margin-top: 6px; }
  #ending-msg { order: 4; font-size: 14px; line-height: 1.45; margin: 6px 0 0; }
  .ending-best { order: 5; margin-top: 4px; }
  .ending-btns { padding: 6px 14px 8px; }
  .ending-btns .btn { min-height: 44px; padding: 4px 12px; }
  .ending-right { padding: 8px 12px; }
}

/* 彈窗 ---------------------------------------------------------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(70, 70, 66, .45);
}
.modal-box {
  position: relative;
  width: min(540px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 20px 22px;
  border: 3px solid #fff;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.modal-box h2 { margin: 0 44px 10px 0; font-size: 23px; }
.modal-x {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink-soft);
  cursor: pointer;
}
/* 關於：小一號的 Q 版卡片 */
.modal[data-variant='about'] .modal-box { width: min(360px, 100%); padding: 18px 20px 20px; border-radius: 26px; text-align: center; }
.modal[data-variant='about'] .modal-box h2 { margin: 6px 44px 10px; font-size: 20px; color: #3f6f58; }
.about p { margin: 0; font-size: 15px; line-height: 1.65; }
.about-links { display: flex; justify-content: center; gap: 10px; margin-top: 14px !important; }
.about-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 4px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.about-link:hover { border-color: var(--orange); color: var(--brand); }
.help-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 13px; font-size: 15.5px; }
.help-list dt { font-weight: 800; color: #4a7c63; }
.help-list dd { margin: 0; }
.help-note { margin: 13px 0 0; padding: 9px 13px; border-radius: 13px; background: var(--cream); font-size: 15px; }
.help-sos { margin-top: 8px; background: #fff0ea; }

.records-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.records-stats > div { padding: 7px 4px; border-radius: 13px; background: var(--cream); text-align: center; }
.records-stats span { display: block; color: var(--ink-soft); font-size: 13px; }
.records-stats b { font-size: 23px; }
.records-best { margin-top: 10px; padding: 9px 13px; border-radius: 13px; background: var(--green-soft); }
.records-best span, .records-best small { display: block; color: var(--ink-soft); font-size: 13px; }
.records-seen { margin: 9px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.records h3 { margin: 12px 0 7px; font-size: 17px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 13px; }
.badge { padding: 8px 12px; border: 2px dashed var(--line); border-radius: 13px; color: var(--ink-soft); }
.badge strong { display: block; font-size: 15px; }
.badge span { font-size: 13px; line-height: 1.4; display: block; }
.badge.on { border: 2px solid #efc76a; background: #fff6da; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* 出發前準備 ------------------------------------------------------- */
#prep-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(90, 110, 100, .28);
  pointer-events: auto !important;
}
.prep-panel {
  width: min(1180px, 100%);
  height: min(860px, 100%);
  display: flex;
  flex-direction: column;
  border: 3px solid #fff;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.prep-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 2px solid var(--cream);
}
.prep-back { flex: none; min-height: 44px; white-space: nowrap; }
.prep-title { flex: 1; min-width: 0; }
.prep-step { display: block; color: var(--brand); font-size: 13px; font-weight: 700; line-height: 1.3; }
.prep-title h2 { margin: 0; font-size: 22px; line-height: 1.3; color: #3f6f58; }
.prep-dots { flex: none; display: flex; gap: 7px; margin: 0; padding: 0; list-style: none; }
.prep-dots li { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.prep-dots li.on { background: var(--brand); box-shadow: 0 0 0 3px rgba(189, 84, 43, .22); }
.prep-dots li.done { background: var(--green); }
.prep-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px 18px 28px;
  scroll-padding-bottom: 28px;
}
.prep-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--cream);
  background: var(--paper);
}
.prep-foot .btn { flex: none; white-space: nowrap; }
.prep-foot-note { flex: 1; min-width: 0; margin: 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.45; }
.prep-note { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

/* 選山 */
.mtn-chips { display: none; }
.mtn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mtn-card {
  display: flex;
  flex-direction: column;
  padding: 9px 12px 11px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.mtn-card.picked { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(189, 84, 43, .16); }
.mtn-banner { width: 100%; height: 84px; display: block; border-radius: 11px; }
.mtn-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 7px; }
.mtn-top h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.mtn-stars { flex: none; color: #d08a1f; font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
.mtn-intro { margin: 1px 0 6px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.mtn-facts { flex: 1; align-content: start; margin: 0 0 8px; display: grid; grid-template-columns: max-content 1fr; gap: 2px 8px; font-size: 14px; line-height: 1.5; }
.mtn-facts dt { color: #4a7c63; font-weight: 800; }
.mtn-facts dd { margin: 0; }
.mtn-pick { width: 100%; min-height: 44px; }
.mtn-pick.on { border-color: var(--brand); background: #fdf0e6; color: var(--brand); }

/* 季節與預報 */
.fc-wrap { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.fc-art { width: 100%; height: 150px; display: block; border-radius: 16px; }
.fc-mtn { margin: 9px 0 0; font-size: 20px; line-height: 1.3; }
.fc-sub { margin: 0 0 9px; color: var(--ink-soft); font-size: 13.5px; }
.season-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.season-btn {
  min-height: 56px;
  padding: 5px 8px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  line-height: 1.3;
}
.season-btn strong { display: block; font-size: 16px; }
.season-btn small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.season-btn:last-child { grid-column: 1 / -1; }
.season-btn:hover { background: #fff5e6; }
.season-btn.on { border-color: var(--brand); background: #fdf0e6; }
.fc-empty { margin: 0; padding: 26px 20px; border: 2px dashed var(--line); border-radius: 18px; color: var(--ink-soft); font-size: 16px; text-align: center; }
.fc-card { padding: 13px 15px; border: 2px solid var(--line); border-radius: 18px; background: #fff; }
.fc-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 7px; }
.fc-title strong { font-size: 19px; }
.fc-notice { color: #a24a24; font-size: 13.5px; font-weight: 700; }
.fc-rows { display: grid; gap: 1px; }
.fc-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.fc-ic { display: grid; place-items: center; }
.fc-label { color: var(--ink-soft); font-size: 14.5px; line-height: 1.4; }
.fc-value { text-align: right; line-height: 1.3; }
.fc-value b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.fc-value small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.fc-hazards { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 9px; }
.hz-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 11px 2px 6px; border-radius: 999px; background: #fff0c9; color: #7f5512; font-size: 14px; font-weight: 700; }
.hz-ic { display: grid; place-items: center; }
.hz-ic svg { width: 17px; height: 17px; }
.hz-none { color: var(--ink-soft); font-size: 14px; }
.fc-tips { margin: 9px 0 0; padding: 7px 11px; border-radius: 12px; background: var(--cream); font-size: 14px; line-height: 1.55; }
.postpone-card { margin-bottom: 12px; padding: 13px 15px; border: 2px solid #efb48c; border-radius: 18px; background: #fff4ea; }
.postpone-card h3 { margin: 0 0 4px; font-size: 19px; color: #a24a24; }
.postpone-card ul { margin: 0 0 4px; padding-left: 20px; font-size: 15px; line-height: 1.55; }
.postpone-card p { margin: 4px 0 9px; font-size: 14.5px; }
.postpone-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.postpone-btns .btn { min-height: 44px; padding: 6px 4px; }

/* 換裝打包 */
.prep-panel[data-step='gear'] .prep-body { padding: 0; overflow: hidden; display: flex; }
.gear-layout { flex: 1; min-width: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.gear-left { display: flex; flex-direction: column; gap: 9px; min-height: 0; padding: 12px 14px; border-right: 2px solid var(--cream); overflow-y: auto; background: #fbf7ea; }
.gear-brief { display: flex; flex-direction: column; font-size: 13.5px; line-height: 1.4; }
.gear-brief strong { font-size: 14.5px; }
.gear-visual { flex: 1 0 auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.gear-stage { position: relative; flex: 1 1 250px; min-height: 200px; max-height: 340px; }
.gear-preview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 16px; }
.gear-tray-slot { flex: none; }
.gear-summary { flex: none; margin: 0; color: #6b5c50; font-size: 13px; line-height: 1.4; text-align: center; }
.gear-tray { padding: 6px 9px; border-radius: 13px; background: #fff; }
.tray-group { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 4px; }
.tray-group + .tray-group { margin-top: 2px; border-top: 1px dashed var(--line); padding-top: 2px; }
.tray-label { color: #4a7c63; font-size: 12px; font-weight: 800; line-height: 1.25; }
.tray-icons { display: flex; flex-wrap: wrap; gap: 2px; }
.tray-item { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 2px solid transparent; border-radius: 9px; background: none; cursor: pointer; touch-action: manipulation; }
.tray-item .gear-icon { background: none; }
.tray-item.on, .tray-item:hover { border-color: var(--orange); background: #fff5e6; }
.tray-name { margin: 2px 0 0; min-height: 18px; color: #6b5c50; font-size: 12px; line-height: 1.5; text-align: center; }
.tray-name.on { color: var(--ink); font-size: 13px; font-weight: 700; line-height: 1.4; }
.gear-tray.empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; }
.tray-empty { margin: 0; color: #6b5c50; font-size: 14px; }
.tray-go { min-height: 44px; }
.gear-meter { padding: 8px 12px 9px; border-radius: 14px; background: #fff; }
.meter-top { display: flex; align-items: baseline; gap: 3px; font-size: 14px; font-weight: 700; }
.meter-num { margin-left: 6px; font-size: 27px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--brand); }
.meter-cap { color: var(--ink-soft); }
.meter-bar { position: relative; height: 10px; border-radius: 5px; background: #eadfc8; overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 5px; transition: width .2s ease; }
.gear-meter > .meter-bar { margin-top: 3px; }
.meter-why { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.45; }
.meter-why li { padding: 1px 0; }
.meter-why li.ok { color: #237a45; }
.meter-more { min-height: 44px; margin: 2px 0 -6px; padding: 0 2px; border: 0; background: none; color: var(--brand); font-size: 13.5px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.gear-stick { flex: none; position: relative; z-index: 3; background: var(--paper); }
.gear-mini { display: none; }
.gear-rec { width: 100%; min-height: 44px; flex: none; }
.gear-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.gear-tabs { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 14px 0; gap: 6px; border-bottom: 2px solid var(--cream); }
.gear-tab {
  min-height: 46px;
  border: 2px solid transparent;
  border-bottom: 0;
  border-radius: 13px 13px 0 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.gear-tab.on { border-color: var(--cream); background: #fff5e6; color: var(--brand); }
.gear-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 10px 14px 28px; scroll-padding-bottom: 28px; }
.gear-slot { margin-bottom: 12px; }
.gear-slot-note { display: none; }
.gear-slot h4 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 0 5px; color: #4a7c63; font-size: 15.5px; }
.gear-target { color: var(--ink-soft); font-size: 12.5px; font-weight: 500; }
.gear-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 7px; }
.gear-opt {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 6px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .14s ease, border-color .14s ease;
}
.gear-opt:hover { background: #fff8ec; }
.gear-opt.on { border-color: var(--pick); background: var(--pick-soft); }
.gear-opt.flash { animation: gear-flash 1.4s ease 2; }
@keyframes gear-flash { 50% { box-shadow: 0 0 0 4px rgba(240, 138, 87, .5); } }
.gear-icon { flex: none; border-radius: 10px; background: var(--cream); }
.gear-opt-text { flex: 1; min-width: 0; line-height: 1.35; }
.gear-opt-name { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.gear-opt-name b { font-size: 16px; }
.gear-opt-name small { flex: none; color: var(--ink-soft); font-size: 12px; }
.gear-opt-teach { display: block; color: #6b5c50; font-size: 14px; line-height: 1.5; }
.gear-opt-mark {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}
.gear-opt.on .gear-opt-mark { width: auto; height: 22px; padding: 0 8px; border-color: var(--pick); border-radius: 999px; background: var(--pick); }
.gear-opt.on .gear-opt-mark::before { content: '已選'; font-size: 12px; }
.group-bars { display: grid; gap: 6px; }
.group-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) 48px; align-items: center; gap: 7px; font-size: 13.5px; }
.group-score { white-space: nowrap; }
.group-name { font-weight: 700; }
.group-score { text-align: right; font-variant-numeric: tabular-nums; }
.group-cap { grid-column: 2 / -1; margin-top: -3px; color: #a24a24; font-size: 12px; }
.review-reasons { margin-top: 12px; }
.review-reasons h4 { margin: 0 0 4px; color: #4a7c63; font-size: 15.5px; }
.review-reasons ul { margin: 0; padding-left: 0; list-style: none; font-size: 14px; line-height: 1.5; }
.review-reasons li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.review-ok { margin: 0; color: #237a45; font-size: 14px; }
.essentials { margin-top: 12px; }
.essentials summary { min-height: 44px; display: flex; align-items: center; color: #4a7c63; font-size: 15.5px; font-weight: 800; cursor: pointer; }
.essentials ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 5px; margin: 0; padding: 0; list-style: none; }
.essentials li { display: grid; grid-template-columns: auto 1fr; gap: 0 7px; align-items: center; padding: 5px 9px; border-radius: 11px; background: var(--cream); font-size: 14px; line-height: 1.35; }
.essentials small { grid-column: 1 / -1; color: var(--ink-soft); font-size: 12.5px; }
.ess-tag { padding: 0 7px; border-radius: 999px; font-size: 12.5px; }
.ess-done .ess-tag { background: var(--green); color: #fff; }
.ess-part .ess-tag { background: #f4c34a; color: #5a4a2a; }
.ess-none .ess-tag { border: 1px dashed #a4907a; color: #7c6c5f; }
.ess-name { font-weight: 700; }

/* 裝備檢查 */
.check-wrap { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.check-left { display: grid; gap: 10px; position: sticky; top: 0; }
.check-total { padding: 10px 14px; border-radius: 16px; background: #fff5e6; text-align: center; }
.check-total span { display: block; font-size: 14px; font-weight: 700; }
.check-total strong { display: block; font-size: 38px; line-height: 1.15; color: var(--brand); font-variant-numeric: tabular-nums; }
.check-total small { display: block; color: var(--ink-soft); font-size: 13px; line-height: 1.4; }
.check-preview { width: 100%; height: 200px; display: block; border-radius: 16px; }
.check-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.check-row {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px 6px 8px;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.check-row.adjust { border-color: #f0c08f; background: #fff8ee; }
.check-row:hover { border-color: var(--orange); }
.check-mark { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-weight: 900; color: #fff; background: var(--green); font-size: 14px; }
.check-row.adjust .check-mark { background: #d98b2b; }
.check-text { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.5; }
.check-text b { display: block; color: var(--ink-soft); font-size: 13px; }
.check-row.adjust .check-text b { color: #a24a24; }
.check-pts { flex: none; color: #a24a24; font-size: 15px; font-weight: 800; }

/* 遊戲中的山岳與裝備資訊 */
.hud-trip { margin: 5px 0 -5px; overflow: hidden; color: var(--ink-soft); font-size: 12.5px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.card-gear-note { margin: -4px 0 10px; padding: 4px 10px; border-radius: 10px; background: #fff3dc; color: #7f5512; font-size: 14px; line-height: 1.45; }
.fb-gear { margin: 7px 0 4px; padding: 7px 11px; border-left: 4px solid var(--orange); border-radius: 4px 10px 10px 4px; background: rgba(255, 253, 246, .85); font-size: 15px; line-height: 1.5; }
.fb-gear.less, .fb-gear.tip { border-left-color: var(--green); }
.fb-gear p { margin: 2px 0 0; }
.fb-gear-main { font-weight: 700; }
.fb-gear details { margin-top: 3px; font-size: 13.5px; }
.fb-gear summary { min-height: 32px; display: flex; align-items: center; color: var(--ink-soft); cursor: pointer; }

/* 結局的山岳摘要與回顧卡 */
.ending-trip { margin: 4px 0 2px; padding: 4px 10px; border-radius: 10px; background: #e2f2ea; color: #2f6e50; font-size: 14px; font-weight: 700; line-height: 1.45; }
#ending-prep { display: grid; gap: 8px; margin-bottom: 10px; }
#ending-prep[hidden] { display: none; }
.trip-card { border: 2px solid #f0c08f; border-radius: 15px; background: #fff; }
.trip-card summary { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 7px 12px; list-style: none; cursor: pointer; }
.trip-card summary::-webkit-details-marker { display: none; }
.trip-card summary::after { content: ''; flex: none; width: 8px; height: 8px; margin: -3px 3px 0 2px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(45deg); }
.trip-card[open] summary::after { margin-top: 3px; transform: rotate(-135deg); }
.trip-score { flex: none; color: #a24a24; font-size: 14px; font-weight: 700; }
.trip-body { padding: 0 13px 11px; font-size: 14.5px; line-height: 1.5; }
.trip-body h4 { margin: 8px 0 2px; font-size: 14.5px; color: #4a7c63; }
.trip-body p { margin: 3px 0; }
.trip-body ul { margin: 0; padding-left: 18px; }
.trip-groups { display: flex; flex-wrap: wrap; gap: 3px 12px; padding: 0 !important; list-style: none; font-weight: 700; }
.trip-total { font-weight: 700; }
.trip-note { color: var(--ink-soft); font-size: 13px; }
.trip-log { padding: 0 !important; list-style: none; }
.trip-log li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.trip-log b { display: block; }
.trip-recon { margin-top: 7px !important; padding: 4px 9px; border-radius: 9px; background: var(--cream); font-weight: 700; }
.ending-btns.has-trip { grid-template-columns: 1fr 1fr; }
.ending-btns.has-trip #btn-again { grid-column: 1 / -1; }

/* 矮桌機放不下整欄，改跟著一起捲，避免下半被切掉 */
@media (max-height: 800px) {
  .check-left { position: static; }
  .gear-stage { flex-basis: 210px; }
}
@media (min-width: 761px) and (min-height: 521px) {
  /* 內容少的步驟不留一大片空白 */
  .prep-panel[data-step='forecast'] { height: auto; max-height: 100%; }
}

/* 手機：單欄，一次一張主要卡片 */
@media (max-width: 760px) {
  #prep-screen { padding: 0; background: var(--paper); }
  .prep-panel { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .prep-head { padding: calc(6px + env(safe-area-inset-top)) 10px 6px; gap: 8px; }
  .prep-back { padding: 4px 10px; font-size: 13.5px; }
  .prep-title h2 { font-size: 18px; }
  .prep-step { font-size: 12px; }
  .prep-dots { display: none; }
  .prep-body { padding: 8px 10px; }
  .prep-foot { padding: 7px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  .prep-foot-note { font-size: 12.5px; }
  .prep-foot .btn { padding: 8px 14px; font-size: 15px; }
  .prep-panel[data-step='mountain'] .prep-foot { flex-wrap: wrap; gap: 2px 8px; }
  .prep-panel[data-step='mountain'] #prep-next { margin-left: auto; }

  .mtn-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
  .mtn-chip {
    min-height: 44px;
    padding: 2px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
  }
  /* 瀏覽中：淡底加底線；真的選了才有勾與品牌色框 */
  .mtn-chip.on { border-color: var(--line); border-bottom: 3px solid var(--brand); background: #fff8ee; }
  .mtn-chip.picked { color: var(--brand); border-color: var(--brand); }
  .mtn-grid { display: block; }
  .mtn-card { display: none; }
  .mtn-card.active { display: flex; }
  .mtn-banner { height: 112px; }
  .mtn-top h3 { font-size: 20px; }
  .mtn-intro { font-size: 14.5px; }
  .mtn-facts { font-size: 14.5px; gap: 4px 8px; }

  .fc-wrap { display: block; }
  .fc-art { height: 84px; }
  .fc-mtn { margin-top: 5px; font-size: 18px; }
  .fc-sub { margin-bottom: 5px; }
  .season-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 8px; }
  .season-btn { min-height: 48px; padding: 2px; border-radius: 11px; }
  .season-btn strong { font-size: 14.5px; }
  .season-btn small { display: none; }
  .season-btn:last-child { grid-column: auto; }
  .fc-card { padding: 9px 11px; }
  .fc-title strong { font-size: 17px; }
  .fc-notice { font-size: 12.5px; line-height: 1.4; }
  .fc-row { padding: 3px 0; }
  .fc-label { font-size: 13.5px; }
  .fc-value b { font-size: 16px; }
  .fc-value small { font-size: 12px; }
  .fc-tips { font-size: 13px; padding: 5px 9px; line-height: 1.45; }

  /* 換裝：整頁單一主捲動區；分頁置頂，捲過預覽後貼一條小摘要 */
  .prep-panel[data-step='gear'] .prep-body { display: block; position: relative; overflow-y: auto; }
  .gear-layout { display: block; width: 100%; }
  .gear-left { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 5px 8px; padding: 6px 10px; border-right: 0; border-bottom: 2px solid var(--cream); overflow: visible; }
  .gear-brief { grid-column: 1 / -1; font-size: 12px; line-height: 1.32; }
  .gear-brief strong { font-size: 13px; }
  .gear-visual { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 6px; }
  .gear-stage { min-height: 170px; max-height: none; }
  .gear-summary { grid-column: 1 / -1; font-size: 12.5px; }
  .gear-tray { height: 100%; padding: 4px 6px; }
  .gear-tray.empty { flex-direction: column; }
  .tray-group { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tray-label { font-size: 12px; }
  .tray-item { width: 30px; height: 30px; }
  .tray-item .gear-icon { width: 25px !important; height: 25px !important; }
  .gear-meter { grid-column: 1; padding: 3px 9px 5px; min-width: 0; }
  .meter-num { font-size: 21px; }
  .meter-top { font-size: 13px; }
  .meter-why { margin-top: 2px; font-size: 13px; line-height: 1.4; }
  .gear-rec { grid-column: 2; width: 100%; height: 100%; min-height: 44px; padding: 2px 6px; font-size: 13px; line-height: 1.25; }
  .gear-right { display: block; }
  .gear-stick { position: sticky; top: 0; }
  .gear-tabs { padding: 4px 10px 0; background: var(--paper); }
  .gear-mini {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 62px;
    align-items: center;
    gap: 8px;
    padding: 3px 10px;
    border-bottom: 2px solid var(--cream);
    background: #fbf7ea;
    box-shadow: 0 3px 8px rgba(90, 70, 50, .12);
  }
  .gear-mini.show { display: flex; }
  .gear-mini-art { flex: none; width: 46px; height: 54px; border-radius: 9px; }
  .gear-mini-text { flex: 1; min-width: 0; margin: 0; font-size: 13px; font-weight: 700; line-height: 1.35; }
  .gear-scroll { overflow: visible; padding: 8px 10px 28px; }
  .gear-opts { grid-template-columns: 1fr; }
  /* 短選項兩欄；說明移到清單下方，只顯示目前所選 */
  .gear-opts.is-short { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .is-short .gear-opt { min-height: 52px; gap: 6px; padding: 4px 6px 4px 4px; }
  .is-short .gear-icon { width: 32px !important; height: 32px !important; }
  .is-short .gear-opt-teach { display: none; }
  .is-short .gear-opt-name b { font-size: 15px; line-height: 1.25; }
  .is-short .gear-opt-mark { width: 20px; height: 20px; font-size: 12px; }
  .gear-slot-note { display: block; margin: 4px 2px 0; color: #6b5c50; font-size: 14px; line-height: 1.5; }

  .check-wrap { display: block; }
  .check-left { position: static; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 9px; }
  .check-total { padding: 6px 4px; }
  .check-total strong { font-size: 25px; }
  .check-total small { display: none; }
  .check-left .group-bars { gap: 3px; }
  .check-left .group-row { grid-template-columns: 58px minmax(0, 1fr) 42px; gap: 5px; font-size: 12.5px; }
  .check-preview, .check-left .gear-tray { display: none; }
  .essentials ul { grid-template-columns: 1fr; }
}
/* 短螢幕直式手機：縮小預覽，把高度讓給選項 */
@media (max-width: 760px) and (max-height: 700px) {
  .gear-brief { display: block; line-height: 1.3; }
  .gear-brief strong { display: block; }
  .gear-brief span + span::before { content: '；'; }
  .gear-stage { min-height: 120px; }
  .tray-group { grid-template-columns: 28px minmax(0, 1fr); gap: 3px; align-items: start; }
  .tray-label { font-size: 12px; line-height: 1.15; }
  .tray-item { width: 26px; height: 26px; }
  .tray-item .gear-icon { width: 22px !important; height: 22px !important; }
  .tray-name { display: none; }
  .tray-name.on { display: block; }
  .gear-meter { padding: 2px 9px 6px; }
  .prep-foot-note { display: none; }
  .prep-foot .btn { flex: 1; }
}
/* 橫式手機：左右兩欄，高度吃緊 */
@media (max-height: 520px) and (orientation: landscape) {
  #prep-screen { padding: 0; }
  .prep-panel { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .prep-head { padding: 3px 10px; }
  .prep-title h2 { font-size: 17px; }
  .prep-step { display: none; }
  .prep-body { padding: 6px 10px; }
  .prep-foot { padding: 3px 10px 4px; }
  .prep-foot .btn { min-height: 44px; padding: 4px 14px; }
  .gear-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .gear-left { padding: 6px 8px; gap: 5px; }
  .gear-stage { flex: none; height: 170px; min-height: 0; }
  .gear-brief { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gear-opt.flash { outline: 3px solid var(--orange); }
}

/* 保命觀念：題卡徽章、作答重點、結局清單 */
.card.is-key { border-color: #f7b9a4; }
.card.is-key.is-right { border-color: #9fdcb0; }
.card.is-key.is-wrong { border-color: #f4a79f; }
.key-strip { flex: none; padding: 8px 14px 7px; border-radius: 21px 21px 0 0; background: linear-gradient(90deg, #ffe3d3, #fff2e4); }
.key-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 2px 13px 2px 3px;
  border-radius: 999px;
  background: #fffaf4;
  color: #a92f28;
}
.key-ring { flex: none; display: block; }
.key-badge-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 7px; min-width: 0; line-height: 1.3; }
.key-badge small { font-size: 12.5px; font-weight: 800; letter-spacing: .04em; }
.key-badge b { font-size: 15px; font-weight: 800; }
.fb-key { margin: 7px 0 4px; padding: 3px 0 3px 11px; border-left: 4px solid #ee8b70; }
.fb-key p { margin: 0; }
.fb-key-point { font-size: 15.5px; line-height: 1.55; font-weight: 400; color: #5a3a30; }
.fb-key-label { display: block; color: #a92f28; font-size: 13px; font-weight: 800; line-height: 1.5; }
.fb-key-point strong { font-weight: 800; color: #6e2a22; }
.fb-key-src { margin-top: 3px !important; font-size: 13px; line-height: 1.5; color: #6b5c50; }
.fb-key-src a, .fb-src a, .sum-src a { color: #8a4326; text-underline-offset: 2px; }
.ending-key { margin: 0 0 10px; padding: 9px 12px 11px; border: 2px solid #f3a48c; border-radius: 15px; background: #fff6ee; }
.ending-key h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 7px; color: #a92f28; font-size: 16px; }
.ending-key h4 span { margin-left: auto; color: #7c5a4c; font-size: 13.5px; font-weight: 700; }
.ending-key ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.ending-key-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; padding: 3px 5px 3px 11px; border-radius: 10px; background: #fff; font-size: 15px; font-weight: 600; line-height: 1.35; }
.ending-key-name { min-width: 0; }
.ending-key-status { flex: none; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.ending-key-item.ok .ending-key-status { background: var(--green-soft); color: #1f7040; }
.ending-key-item.ng .ending-key-status { background: #fde8e4; color: #a92f28; }
.ending-key-item.skip .ending-key-status { background: var(--cream); color: var(--ink-soft); }
.ending-key-status::before { margin-right: 4px; }
.ending-key-item.ok .ending-key-status::before { content: '✓'; }
.ending-key-item.ng .ending-key-status::before { content: '!'; }
.ending-key-item.skip .ending-key-status::before { content: '–'; }
.sum-item.is-key .sum-title::before { content: '保命'; display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 999px; background: #ffe2d4; color: #a92f28; font-size: 12px; font-weight: 800; line-height: 1.6; vertical-align: 1px; }
@media (max-height: 520px) and (orientation: landscape) {
  .key-strip { padding: 4px 12px 3px; border-radius: 15px 15px 0 0; }
  .key-ring { width: 22px; height: 22px; }
}
@media (max-width: 900px) and (orientation: portrait) {
  /* 固定區內徽章兩行收窄，把寬度留給題名 */
  .card-fixed .key-badge { padding: 1px 10px 1px 2px; gap: 5px; }
  .card-fixed .key-ring { width: 26px; height: 26px; }
  .card-fixed .key-badge-text { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; line-height: 1.2; }
  .card-fixed .key-badge small { font-size: 12px; }
  .card-fixed .key-badge b { font-size: 13.5px; }
}

/* 出發前夜的主視覺 */
#start-screen { background: url("assets/art/key-art.jpg") 72% center / cover no-repeat; }
.gear-eve { margin: 0 0 4px; color: var(--brand); font-size: 14px; font-weight: 800; }
.meter-pending { margin: 6px 0 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.45; }
#prep-next.is-pending { background: #6d7f72; box-shadow: 0 3px 0 #53635a; }
.gear-slot:has(.gear-opt.on) > h4 { color: inherit; }
.gear-rec[hidden] { display: none; }

/* 選山：卡片本身可點，細節收進摺疊 */
.mtn-card { cursor: pointer; }
.mtn-banner { height: 132px; }
.mtn-more { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.mtn-more summary { min-height: 32px; color: #4a7c63; font-weight: 800; cursor: pointer; }
#prep-panel[data-step="mountain"] .prep-foot-note { color: var(--ink); }

/* 結局：這趟的足跡 */
.ending-trail { margin: 0 0 10px; padding: 10px 12px 12px; border: 2px solid #bcdcc7; border-radius: 15px; background: #fff; }
.ending-trail h4 { margin: 0 0 4px; color: #2f6b52; font-size: 16px; }
.ending-trail svg { display: block; width: 100%; height: auto; }
.trail-area { fill: #e3f0df; }
.trail-line { fill: none; stroke: #5fa781; stroke-width: 2.5; stroke-linejoin: round; }
.trail-ok { fill: #2f8f62; stroke: #fff; stroke-width: 2; }
.trail-ng { fill: #d0482f; stroke: #fff; stroke-width: 2; }
.trail-label { fill: #6d6255; font-size: 13px; font-weight: 700; }
.trail-legend { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }
.trail-legend i { width: 10px; height: 10px; border-radius: 50%; }
.trail-legend i.dot-ng { margin-left: 8px; background: #d0482f; }
.trail-legend i.dot-ok { background: #2f8f62; }
.trail-worst { margin: 8px 0 0; padding: 7px 10px; border-radius: 10px; background: #fff1e8; font-size: 14.5px; line-height: 1.5; }
.trail-worst b { display: block; color: #a92f28; font-size: 13px; }
.trail-body { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.5; }
.trail-body li { padding: 3px 0 3px 10px; border-left: 3px solid #d9d2c3; margin-bottom: 4px; }
.trail-body li.warn { border-color: #e29a4f; }
.trail-body li.good { border-color: #7dbf8b; }

@media (max-width: 760px) {
  /* 手機保留畫面右下角的登山客 */
  #start-screen { background-position: 87% bottom; }
}

/* 3D 場景在最底層，2D 畫布只疊泡泡與浮字 */
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#scene3d[hidden] { display: none; }
#scene.overlay { background: transparent; }
#app.is-3d #start-screen { background: none; }
#app.is-3d.at-ending { background: linear-gradient(#7fb4e6, #ffe2c0); }
#app.is-3d.at-ending #scene3d { visibility: hidden; }
#app.is-3d.at-ending.cine #scene3d { visibility: visible; }

/* 重要時刻：開場、登頂、結局。介面先退開，把畫面留給場景 */
#cine-title {
  position: absolute; left: 12px; right: 12px; top: 11%; z-index: 30; pointer-events: none; text-align: center;
  color: #fff; text-shadow: 0 2px 18px rgba(30, 40, 50, .55), 0 1px 3px rgba(30, 40, 50, .5);
  animation: cine-in .9s ease both;
}
#cine-title[hidden] { display: none; }
#cine-title p { margin: 0 0 6px; font-size: clamp(16px, 2.2vw, 22px); font-weight: 800; letter-spacing: .08em; }
#cine-title strong { display: block; font-size: clamp(40px, 7vw, 84px); font-weight: 800; line-height: 1.15; letter-spacing: .04em; }
#cine-title span { display: block; margin-top: 8px; font-size: clamp(15px, 2vw, 20px); font-weight: 700; }
@keyframes cine-in { from { opacity: 0; transform: translateY(14px); } }
#app.moment #hud, #app.moment #controls, #app.moment #hints, #app.moment #actions { opacity: 0; pointer-events: none; }
#hud, #controls, #hints, #actions { transition: opacity .35s ease; }
#app.cine #ending-screen { background: transparent; cursor: pointer; }
#app.cine .ending-panel { opacity: 0; pointer-events: none; transform: translateY(24px); }
.ending-panel { transition: opacity .55s ease, transform .55s ease; }
#ending-bg { display: none; }
#app.is-3d #ending-bg { display: block; position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(7px) saturate(1.05) brightness(1.04); transform: scale(1.04); }
#app.cine #ending-bg { visibility: hidden; }
#app.cine ~ .more-hint { display: none; }
.ending-panel { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  #cine-title { animation: none; }
  .ending-panel, #hud, #controls, #hints, #actions { transition: none; }
}

/* 明白告訴玩家清單還能往下捲 */
.more-hint {
  position: fixed; z-index: 40; transform: translateX(-50%); min-height: 30px; padding: 4px 14px;
  border: 0; border-radius: 999px; background: rgba(47, 107, 82, .92); color: #fff; font-size: 13.5px; font-weight: 800;
  box-shadow: 0 3px 10px rgba(40, 50, 40, .22); cursor: pointer; font-family: inherit;
}
.more-hint[hidden] { display: none; }

/* 裝備檢查：先給三件最有用的，其他收起來 */
.check-top-title { margin: 0 0 8px; color: #b0491f; font-size: 16px; }
.check-more { margin: 10px 0 0; }
.check-more summary { min-height: 40px; padding: 9px 12px; border-radius: 12px; background: #f6efdd; font-size: 14.5px; font-weight: 800; cursor: pointer; }
.check-more .check-list { margin-top: 8px; }

/* 手機的換裝頁：把高度讓給要做選擇的清單 */
@media (max-width: 760px) and (orientation: portrait) {
  .gear-eve, .gear-brief span, .meter-pending, .gear-summary { display: none; }
  .gear-left { padding: 6px 10px; gap: 4px; }
  .gear-brief strong { font-size: 12.5px; }
  .gear-stage { min-height: 0; height: 118px; }
  .gear-meter { padding: 5px 10px; }
}

/* 答錯回饋：先看自己選了什麼，細節要看再展開 */
.fb-chosen { flex-basis: 100%; margin: 2px 0 0; color: #7a3a2c; font-size: 14px; font-weight: 700; line-height: 1.45; }
.fb-head { flex-wrap: wrap; }
.fb-more summary { min-height: 36px; display: flex; align-items: center; color: #4a7c63; font-size: 14.5px; font-weight: 800; cursor: pointer; }
.fb-more.is-plain summary { display: none; }
.fb-more p { margin: 4px 0 0; }

.essentials summary::after { content: '▾'; margin-left: 8px; font-size: 13px; }
.essentials[open] summary::after { content: '▴'; }

@media (max-width: 760px) and (orientation: portrait) {
  /* 上面只隱藏說明段落；天氣仍要留著，選裝備要靠它判斷 */
  .gear-brief span { display: inline; font-size: 12px; }
  .gear-brief { display: block; line-height: 1.35; }
  .gear-brief strong { display: block; }
  .gear-brief span + span::before { content: '；'; }
  /* 衣物選項也附上用途，手機玩家才有判斷依據 */
  .gear-opts.is-short { grid-template-columns: 1fr; }
  .is-short .gear-opt-teach { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; line-height: 1.4; }
  .gear-slot-note { display: none; }
}

/* 觀察現場：標記釘在場景物件上，說明面板在下方 */
#observe { position: absolute; inset: 0; z-index: 28; pointer-events: auto; }
#observe[hidden] { display: none; }
#observe-spots { position: absolute; inset: 0; }
#observe-spots.as-list { inset: 8px 8px auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#observe-spots.as-list .observe-spot { position: relative; }
.observe-spot {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 13px 4px 5px;
  border: 2px solid #fff; border-radius: 999px; background: rgba(52, 44, 38, .9); color: #fff; font: inherit; font-size: 15px; font-weight: 800;
  pointer-events: auto; cursor: pointer; box-shadow: 0 3px 12px rgba(20, 20, 20, .35); touch-action: manipulation;
}
.observe-spot::after { content: ''; position: absolute; inset: -5px; border: 2px solid rgba(255, 255, 255, .7); border-radius: inherit; pointer-events: none; animation: spot-pulse 1.7s ease-out infinite; }
.observe-spot.seen { border-color: #d8cdbd; background: rgba(250, 245, 233, .94); color: #4c4037; }
.observe-spot.seen::after { display: none; }
.observe-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--pick); color: #fff; font-size: 14px; }
.observe-spot.seen .observe-num { background: #b5a899; }
@keyframes spot-pulse { from { opacity: .9; transform: scale(.94); } to { opacity: 0; transform: scale(1.22); } }
#observe-panel {
  position: absolute; left: 50%; bottom: 14px; width: min(560px, calc(100% - 20px)); transform: translateX(-50%);
  padding: 12px 16px 14px; border-radius: 18px; background: rgba(255, 252, 243, .96); box-shadow: 0 8px 26px rgba(30, 30, 30, .28); pointer-events: auto;
  max-height: calc(100% - 180px); overflow-y: auto; overscroll-behavior: contain;
}
#observe-kicker { margin: 0; color: #a6562a; font-size: 13.5px; font-weight: 800; }
#observe-title { display: block; margin: 1px 0 6px; font-size: 21px; line-height: 1.25; }
#observe-notes { margin: 0 0 9px; padding: 0; list-style: none; display: grid; gap: 5px; }
#observe-notes:empty { display: none; }
#observe-notes li { display: flex; gap: 8px; font-size: 15px; line-height: 1.45; animation: note-in .25s ease; }
#observe-notes b { flex: none; color: #a6562a; }
@keyframes note-in { from { opacity: 0; transform: translateY(5px); } }
#observe-go { width: 100%; min-height: 46px; }
#observe-go.is-waiting { background: #e3dacb; color: #6a5c50; box-shadow: none; cursor: default; }
@media (prefers-reduced-motion: reduce) { .observe-spot::after { animation: none; } #observe-notes li { animation: none; } }

.card-seen { margin: 7px 0 0; color: #7c6b5c; font-size: 13.5px; font-weight: 700; }
.fb-world { margin: 8px 0; padding: 9px 12px; border-left: 4px solid var(--pick); border-radius: 6px; background: #fbf3e5; }
.fb-world p { margin: 0; font-size: 15px; line-height: 1.5; }
.fb-world-text { font-weight: 700; }
.fb-world-missed { margin-top: 5px !important; color: #6b5c50; font-size: 14px !important; }

.ess-gaps { margin: 12px 0 0; padding: 11px 13px; border: 2px solid #eec9a6; border-radius: 14px; background: #fff6ea; }
.ess-gaps h4 { margin: 0 0 6px; color: #a6562a; font-size: 16px; }
.ess-gaps ul { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 5px; }
.ess-gaps li { display: grid; gap: 1px; font-size: 14.5px; line-height: 1.4; }
.ess-gaps li span { color: #6b5c50; font-size: 13.5px; }
.ess-gaps-ok { margin: 0; font-weight: 700; }
.ess-gaps-fix { min-height: 42px; }

.gear-mini-text { white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* 開場選角色：沿用裝備「已選」的顏色，不用性別色 */
.hero-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; padding: 0; border: 0; }
.hero-pick legend { margin-bottom: 6px; padding: 0; font-size: 15px; font-weight: 800; color: #4c4037; }
.hero-opt { position: relative; display: block; cursor: pointer; }
.hero-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.hero-opt span { display: grid; place-items: center; min-height: 44px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 800; font-size: 16px; }
.hero-opt input:checked + span { border-color: var(--pick); background: var(--pick-soft); }
.hero-opt input:focus-visible + span { outline: 3px solid #2f6b52; outline-offset: 2px; }
.hero-switch { position: absolute; left: 6px; top: 6px; z-index: 2; min-height: 44px; padding: 4px 12px; font-size: 13.5px; }

/* 動用救援的結局：檢討寫清楚，不給獎勵 */
#ending-safety { margin: 0 0 12px; padding: 9px 12px; border-left: 4px solid #c9412f; border-radius: 6px; background: #fdeee9; color: #7d2a1c; font-size: 15px; font-weight: 800; line-height: 1.5; }
#ending-safety[hidden], #ending-review[hidden] { display: none; }
#ending-screen[data-tier='bad'] .ending-stats { grid-template-columns: repeat(2, 1fr); }
#ending-screen[data-tier='bad'] .ending-stats > div:nth-child(3) { display: none; }
#ending-review { margin: 0 0 12px; padding: 11px 14px; border: 2px solid #eec0ae; border-radius: 14px; background: #fff6f1; }
#ending-review h4 { margin: 0 0 5px; color: #a3381f; font-size: 16px; }
#ending-review ul, #ending-review ol { margin: 0 0 9px; padding-left: 20px; display: grid; gap: 4px; font-size: 14.5px; line-height: 1.5; }
#ending-review ol:last-child, #ending-review ul:last-child { margin-bottom: 0; }
@media (max-width: 760px) and (orientation: portrait) {
  #ending-safety { margin: 6px 0 0; font-size: 14px; }
}

/* 拍照：相框蓋在推近的鏡頭上 */
#photo-mode { position: absolute; inset: 0; z-index: 34; }
#photo-mode[hidden] { display: none; }
#photo-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#photo-flash.go { animation: photo-flash .42s ease-out; }
@keyframes photo-flash { 0% { opacity: .95; } 100% { opacity: 0; } }
#photo-view { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; background: rgba(24, 28, 30, .58); animation: photo-in .32s ease both; }
#photo-view[hidden] { display: none; }
@keyframes photo-in { from { opacity: 0; } }
#photo-frame { display: block; flex: 0 1 auto; width: auto; height: auto; max-width: min(100%, 560px); max-height: calc(100% - 96px); min-height: 0; border-radius: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, .4); animation: photo-pop .36s cubic-bezier(.2, 1.1, .4, 1) both; }
@keyframes photo-pop { from { transform: scale(.94); } }
#photo-count { margin: 0; color: #fff; font-size: 14px; font-weight: 700; }
.photo-btns { display: flex; gap: 8px; }
.photo-btns .btn { min-width: 120px; min-height: 44px; }
@media (prefers-reduced-motion: reduce) { #photo-view, #photo-frame { animation: none; } }

/* 結局頁的相簿 */
.ending-photos { margin: 0 0 14px; }
.ending-photos[hidden] { display: none; }
.ending-photos h3 { margin: 0 0 8px; }
#album-big { display: block; width: min(100%, 340px); height: auto; margin: 0 auto; border: 1px solid #e6dfd2; border-radius: 10px; }
#album-thumbs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 0; }
#album-thumbs[hidden] { display: none; }
.album-thumb { padding: 0; width: 56px; height: 70px; border: 2px solid #e6dfd2; border-radius: 8px; overflow: hidden; background: none; cursor: pointer; }
.album-thumb[aria-pressed='true'] { border-color: var(--pick); }
.album-thumb canvas { display: block; width: 100%; height: 100%; }
#album-save { display: block; width: min(100%, 340px); min-height: 44px; margin: 8px auto 0; }
@media (max-width: 760px) and (orientation: portrait) {
  .hero-switch { left: 3px; top: 3px; width: 44px; height: 44px; padding: 0; border-radius: 10px; font-size: 11.5px; line-height: 1.15; white-space: nowrap; }
}

/* 手機答完先看現場：卡片只留結果和一句回應 */
.card.fb-brief { max-height: none !important; }
.card.fb-brief .card-fixed-title, .card.fb-brief .card-main, .card.fb-brief #card-opts,
.card.fb-brief #fb-key, .card.fb-brief #fb-gear, .card.fb-brief #fb-more, .card.fb-brief #fb-src,
.card.fb-brief .fb-chosen, .card.fb-brief .fb-world-missed { display: none !important; }
.card.fb-brief .card-scroll { overflow: visible; padding-bottom: 6px; }

.card-seen { font-weight: 500; color: #4c4037; font-size: 14.5px; line-height: 1.45; }
.card-seen[hidden] { display: none; }
.card-seen summary { display: flex; align-items: center; min-height: 40px; color: #a6562a; font-size: 14px; font-weight: 700; cursor: pointer; }
.card-seen summary::before { content: '▸'; margin-right: 6px; }
.card-seen[open] summary::before { content: '▾'; }
.card-seen span { display: block; margin-bottom: 2px; }
.fb-world-real { margin-top: 6px !important; padding-top: 6px; border-top: 1px dashed #dcc9ae; color: #7a4a22; font-size: 14px !important; font-weight: 700; }
#ending-review.is-lesson { border-color: #eec9a6; background: #fff6ea; }
#ending-review.is-lesson h4 { color: #a6562a; }

/* 標語：短句、品牌色、兩側細線，和一般說明文字分得開 */
.slogan { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--brand); font-size: 15px; font-weight: 800; letter-spacing: .1em; line-height: 1.4; text-align: center; }
.slogan::before, .slogan::after { content: ''; flex: 1 1 18px; min-width: 14px; height: 2px; border-radius: 2px; background: currentColor; opacity: .28; }
.slogan:empty { display: none; }
.start-slogan { margin: 10px 0 4px; }
#ending-slogan { margin: 2px 0 6px; }
@media (max-width: 760px) and (orientation: portrait) {
  #ending-slogan { order: 3; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #ending-slogan { order: 1; margin: 0; font-size: 13px; }
}

/* 手機存圖：長按大圖儲存 */
.save-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(70, 60, 50, .62);
  font-family: var(--font);
  color: var(--ink);
  animation: photo-in .28s ease both;
}
.save-sheet-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(460px, 100%);
  max-height: 100%;
  padding: 16px 16px 18px;
  border: 4px solid #fff;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow), 0 6px 0 var(--line);
}
.save-sheet-tip {
  margin: 0;
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--pick-soft);
  color: var(--brand);
  font-size: 20px;
  font-weight: 800;
}
.save-sheet-sub { margin: 0; font-size: 14px; color: var(--ink-soft); text-align: center; }
.save-sheet-img {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100dvh - 210px);
  object-fit: contain;
  border: 3px solid var(--line);
  border-radius: 18px;
  /* 讓 iOS 長按跳出存圖選單，而不是選取文字 */
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
}
.save-sheet-close { min-width: 140px; }
