:root {
  --paper: #efe6d2;
  --paper2: #e4d7bb;
  --card: #fbf5e8;
  --ink: #3b2c22;
  --ink2: #6b5646;
  --line: #cdbb98;
  --accent: #c2603a;
  --accent-d: #8f4126;
  --gold: #e0b04a;
  --ok: #5f7f45;
  --shadow: 0 6px 24px rgba(50, 30, 15, .25);
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9cbb0; color: var(--ink);
  font-family: 'LXGW WenKai TC', 'Klee One', 'Gowun Dodum', serif; user-select: none; -webkit-user-select: none; touch-action: none; }
html[lang="ja"] body { font-family: 'Klee One', 'LXGW WenKai TC', serif; }
html[lang="ko"] body { font-family: 'Gowun Dodum', 'LXGW WenKai TC', sans-serif; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
/* 手機長按不要跳出系統的「儲存圖片 / 選取文字」選單 */
html, body, button, canvas, img { -webkit-touch-callout: none; }
.hidden { display: none !important; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); font-size: 28px; z-index: 50; transition: opacity .6s; }
#loading.gone { opacity: 0; pointer-events: none; }

/* ── 共用按鈕 ── */
.big { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 21px; padding: 11px 28px; border: 0; background: var(--accent); color: #fff6e6;
  border-radius: 8px 20px 10px 22px; box-shadow: 0 5px 0 var(--accent-d); }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-d); }
.big img { width: 30px; height: 30px; margin: -6px 0; }
.mid { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; padding: 8px 20px; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 18px 8px 16px 10px; box-shadow: 0 3px 0 var(--line); }
.mid img { width: 26px; height: 26px; margin: -4px 0; }
.ghost { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: transparent; border-radius: 22px; padding: 5px 14px; font-size: 14px; color: var(--ink2); }
.ghost img { width: 20px; height: 20px; }
.close { border: 0; background: transparent; font-size: 22px; color: var(--ink2); width: 40px; height: 40px; }

/* ── HUD ── */
#hud { position: fixed; top: calc(12px + var(--sa-t)); left: calc(16px + var(--sa-l)); right: calc(16px + var(--sa-r)); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 10; gap: 10px; }
#hud .left { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#minimap { width: 136px; height: 136px; border-radius: 50%; pointer-events: auto; cursor: pointer; box-shadow: var(--shadow); background: #b8a888; }
.area-box { background: rgba(239, 230, 210, .92); padding: 7px 14px 8px; border-radius: 4px 12px 6px 14px; box-shadow: var(--shadow); min-width: 0; }
#areaName { font-size: 21px; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
.btns { display: flex; gap: 8px; pointer-events: auto; flex-shrink: 0; }
.ib { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--line); background: rgba(239, 230, 210, .94); box-shadow: var(--shadow); display: grid; place-items: center; padding: 0; position: relative; }
.ib img { width: 32px; height: 32px; }
.ib.lang span { position: absolute; right: -4px; bottom: -4px; background: var(--ink); color: var(--paper); font-size: 11px; font-weight: 700; border-radius: 8px; padding: 1px 5px; line-height: 1.3; }
#bJournal.flash { animation: flash 1.4s ease 2; }
@keyframes flash { 50% { background: #f6c27e; transform: scale(1.12); } }
#langMenu { position: fixed; top: calc(66px + var(--sa-t)); right: calc(16px + var(--sa-r)); z-index: 26; background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px 4px 12px 6px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 140px; }
#langMenu button { border: 0; background: transparent; text-align: left; padding: 9px 12px; font-size: 16px; border-radius: 8px; }
#langMenu button.on { background: var(--paper2); font-weight: 700; }

#hint { position: fixed; bottom: calc(18px + var(--sa-b)); left: 50%; transform: translateX(-50%); padding: 7px 16px; border-radius: 14px 6px 12px 8px; font-size: 15px;
  z-index: 9; max-width: calc(100% - 32px); text-align: center; pointer-events: none; }
#hint { background: rgba(239, 230, 210, .9); color: var(--ink2); box-shadow: var(--shadow); }

#exitTags > div { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); background: rgba(58, 44, 34, .82); color: var(--paper); padding: 4px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; pointer-events: none; z-index: 7; }
#exitTags > div.lock { background: rgba(110, 90, 80, .75); }

#toast { white-space: pre-line; position: fixed; top: calc(84px + var(--sa-t)); left: 50%; transform: translate(-50%, -10px); opacity: 0; transition: .35s; background: var(--ink); color: var(--paper); padding: 9px 18px; border-radius: 10px 4px 12px 6px; font-size: 16px; z-index: 20; pointer-events: none; text-align: center; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#areaCard { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; z-index: 15; opacity: 0; transition: opacity .6s; padding: 16px; }
#areaCard.on { opacity: 1; }
#areaCard .t { font-size: clamp(32px, 7vw, 64px); font-weight: 700; letter-spacing: .12em; text-shadow: 0 2px 12px rgba(239, 230, 210, .8); }
#areaCard .s { font-size: 18px; color: var(--ink2); margin-top: 6px; }

/* ── 標題畫面 ── */
#title { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l));
  background: radial-gradient(ellipse at center, rgba(239, 230, 210, .1), rgba(60, 40, 25, .3)); overflow-y: auto; }
#title .sheet { background: rgba(239, 230, 210, .95); padding: 30px 34px 22px; width: min(820px, 100%); display: grid; grid-template-columns: 300px 1fr; gap: 30px; align-items: center;
  border-radius: 6px 18px 8px 22px / 18px 6px 22px 8px; box-shadow: var(--shadow); border: 1.5px solid var(--line); }
#title .hero img { width: 100%; aspect-ratio: 1; display: block; border-radius: 18px 6px 22px 8px; box-shadow: 0 6px 18px rgba(60, 40, 20, .25); transform: rotate(-1.5deg); }
#title .tcol { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
#title h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); letter-spacing: .08em; line-height: 1.15; }
#title p { margin: 0; color: var(--ink2); font-size: 17px; }
#title .prog { margin: -4px 0 0; font-size: 14.5px; color: var(--ink2); letter-spacing: .03em; }
#title .tact { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); margin-top: 6px; }
#title .tact .big, #title .tact .mid { width: 100%; }
.langs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.langs button { border: 1.5px solid var(--line); background: transparent; border-radius: 16px; padding: 4px 12px; font-size: 14px; color: var(--ink2); }
.langs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#title .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#title .credit { font-size: 12px; color: #9a8672; }

/* ── 遊戲說明 ── */
#guide { position: fixed; inset: 0; z-index: 32; background: rgba(40, 28, 20, .5); display: grid; place-items: center; padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l)); overflow-y: auto; }
.gsheet { position: relative; background: var(--paper); width: min(860px, 100%); display: grid; grid-template-columns: 340px 1fr; gap: 28px; padding: 28px; align-items: center;
  border-radius: 6px 18px 8px 22px / 18px 6px 22px 8px; border: 1.5px solid var(--line); box-shadow: var(--shadow); }
.gsheet .close { position: absolute; top: 6px; right: 6px; }
.gart img { width: 100%; aspect-ratio: 1; display: block; border-radius: 16px; box-shadow: 0 4px 14px rgba(60, 40, 20, .2); transform: rotate(-1deg); }
.gnum { font-size: 14px; color: var(--accent); letter-spacing: .1em; }
.gtext h2 { margin: 4px 0 10px; font-size: 28px; }
.gtext p { margin: 0 0 22px; font-size: 17.5px; line-height: 1.75; color: var(--ink2); min-height: 6.5em; }
.gnav { display: flex; align-items: center; gap: 12px; }
.gnav .big { margin-left: auto; font-size: 18px; padding: 9px 22px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); width: 20px; border-radius: 4px; }

/* ── 觸控操作 ── */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 9; }
#stick { position: absolute; left: calc(20px + var(--sa-l)); bottom: calc(26px + var(--sa-b)); width: 132px; height: 132px; border-radius: 50%; background: rgba(239, 230, 210, .3); border: 2px solid rgba(239, 230, 210, .75); pointer-events: auto; touch-action: none; }
#knob { position: absolute; left: 41px; top: 41px; width: 50px; height: 50px; border-radius: 50%; background: rgba(239, 230, 210, .94); box-shadow: var(--shadow); }
/* 右下：大「速寫」鍵 + 弧形排列的種子、小燈 */
.tbtns { position: absolute; right: calc(16px + var(--sa-r)); bottom: calc(22px + var(--sa-b)); width: 186px; height: 176px; pointer-events: none; }
.tb { position: absolute; pointer-events: auto; touch-action: none; border: 2px solid var(--line); background: rgba(239, 230, 210, .94); border-radius: 50%; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; font-size: 12px; line-height: 1; color: var(--ink2); }
.tb img { width: 34px; height: 34px; }
.tb b { position: absolute; right: -2px; top: -2px; background: var(--ink); color: var(--paper); font-size: 12px; border-radius: 9px; padding: 2px 6px; }
#tAtk { right: 0; bottom: 0; width: 98px; height: 98px; background: var(--accent); border-color: var(--accent-d); color: #fff6e6; font-size: 15px; font-weight: 700; }
#tAtk img { width: 48px; height: 48px; margin-bottom: 2px; }
#tAtk:active { transform: scale(.94); background: #a94f2e; }
#tAtk.fire { box-shadow: 0 0 22px rgba(255, 150, 60, .9), var(--shadow); }
#tRoll { left: 0; bottom: 4px; width: 66px; height: 66px; }
#tShd { right: 14px; top: 0; width: 66px; height: 66px; }
#tShd.on { background: #e8d2a0; transform: scale(.94); }
#tAct { left: 6px; top: 4px; width: 66px; height: 66px; background: #fbe3b0; border-color: var(--gold); animation: actPulse 1.2s ease-in-out infinite; }
@keyframes actPulse { 50% { transform: scale(1.07); } }
.tb .tl { font-size: 12px; margin-top: 1px; }

/* 手機直式：底部留給拇指，提示浮在操作區上方 */
@media (orientation: portrait) {
  body.touch #hint { bottom: calc(196px + var(--sa-b)); }
  body.touch #toast { top: calc(74px + var(--sa-t)); }
}
/* 手機橫式：畫面矮，提示移到上方中央，HUD 縮小 */
@media (orientation: landscape) and (max-height: 540px) {
  #hud { top: calc(8px + var(--sa-t)); }
  #areaName { font-size: 16px; }
  .ib { width: 40px; height: 40px; }
  .ib img { width: 27px; height: 27px; }
  #hint { bottom: auto; top: calc(10px + var(--sa-t)); font-size: 14px; max-width: 46%; }
  #toast { top: calc(60px + var(--sa-t)); font-size: 15px; }
  #stick { width: 120px; height: 120px; bottom: calc(18px + var(--sa-b)); left: calc(24px + var(--sa-l)); }
  #knob { left: 35px; top: 35px; }
  .tbtns { transform: scale(.88); transform-origin: right bottom; bottom: calc(14px + var(--sa-b)); right: calc(22px + var(--sa-r)); }
  #areaCard .t { font-size: 34px; }

  #title .sheet { grid-template-columns: 46vh 1fr; gap: 20px; padding: 14px 20px; width: min(760px, 100%); }
  #title h1 { font-size: 26px; }
  #title p { font-size: 13px; }
  #title .tcol { gap: 6px; }
  #title .big { font-size: 17px; padding: 7px 18px; min-width: 200px; margin-top: 0; }
  #title .mid { font-size: 14px; padding: 4px 14px; }
  #title .credit { display: none; }
  #title .prog { margin: 0; font-size: 13px; }
  #title .tfoot { padding-top: 8px; }
  .langs button { padding: 2px 10px; font-size: 13px; }
  #title .ghost { padding: 3px 10px; font-size: 13px; }

  .gsheet { grid-template-columns: 58vh 1fr; gap: 18px; padding: 14px 18px; }
  .gtext h2 { font-size: 21px; margin-bottom: 6px; }
  .gtext p { font-size: 14.5px; line-height: 1.6; min-height: 0; margin-bottom: 12px; }
  .gnav .big { font-size: 16px; padding: 7px 16px; }

}

/* 窄螢幕（手機直式）：標題、說明改成上下排 */
@media (max-width: 720px) and (orientation: portrait) {
  #areaName { font-size: 17px; }
  .btns { gap: 6px; }
  .ib { width: 40px; height: 40px; }
  .ib img { width: 27px; height: 27px; }
  #title .sheet { grid-template-columns: 1fr; gap: 14px; padding: 22px 18px 16px; }
  #title .hero { width: min(52vw, 220px); margin: 0 auto; }
  .gsheet { grid-template-columns: 1fr; gap: 12px; padding: 18px 16px 16px; }
  .gart { width: min(70vw, 300px); margin: 0 auto; }
  .gtext h2 { font-size: 22px; text-align: center; }
  .gnum { text-align: center; }
  .gtext p { font-size: 15.5px; min-height: 7.5em; }
}

/* ── 方向指標：畫面外的出口 ── */
#pointers .ptr { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; display: flex; align-items: center; gap: 6px;
  background: rgba(58, 44, 34, .84); color: var(--paper); padding: 4px 10px 4px 6px; border-radius: 14px; font-size: 13.5px; white-space: nowrap; box-shadow: 0 3px 10px rgba(30, 20, 10, .25); }
#pointers .ptr.lock { background: rgba(110, 90, 80, .8); }
#pointers .ptr i { width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 12px solid #f6c27e; display: block; }

/* ── 大地圖 ── */
#bigmap { position: fixed; inset: 0; z-index: 26; background: rgba(40, 28, 20, .5); display: grid; place-items: center; padding: calc(12px + var(--sa-t)) calc(12px + var(--sa-r)) calc(12px + var(--sa-b)) calc(12px + var(--sa-l)); }
.mapsheet { background: var(--paper); border: 1.5px solid var(--line); border-radius: 6px 18px 8px 22px / 18px 6px 22px 8px; box-shadow: var(--shadow); padding: 12px 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; max-height: 100%; }
.mhead { display: flex; align-items: center; gap: 8px; width: 100%; }
.mhead img { width: 32px; height: 32px; }
.mhead h2 { margin: 0; font-size: 22px; flex: 1; }
#mapCanvas { width: min(78vh, 86vw, 560px); height: min(78vh, 86vw, 560px); border-radius: 10px; box-shadow: inset 0 0 0 2px var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 13.5px; color: var(--ink2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.lg-you { background: #fff6e6; border: 2px solid #3b2c22; box-shadow: 4px 0 0 -1px #c2603a; }
.lg-exit { background: #3b2c22; border-radius: 2px !important; transform: rotate(45deg) scale(.85); }
.lg-cover { background: #4f7a38; border-radius: 2px 2px 6px 6px !important; }
.lg-rock { background: #78706a; }
.lg-fire { background: radial-gradient(circle, #ffbe50, #e86e28); }
@media (orientation: landscape) and (max-height: 540px) {
  #minimap { width: 96px; height: 96px; }
  #hud .left { gap: 6px; }
  #mapCanvas { width: min(70vh, 60vw); height: min(70vh, 60vw); }
  .mapsheet { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 8px 12px; }
  .mhead { width: auto; flex-direction: column; }
  .legend { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 720px) and (orientation: portrait) {
  #minimap { width: 104px; height: 104px; }
}

/* ── 電腦版右下道具列：速寫 / 種子（剩餘數量＋補充進度）/ 小燈，每張標出按鍵 ── */
#tools { position: fixed; right: 18px; bottom: 18px; display: flex; gap: 10px; z-index: 9; }
.tool { position: relative; width: 82px; height: 92px; border: 1.5px solid var(--line); background: rgba(239, 230, 210, .94); border-radius: 12px 6px 14px 8px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 4px 0; gap: 1px; }
.tool img { width: 42px; height: 42px; }
.tool .tl { font-size: 14px; color: var(--ink); line-height: 1.1; }
.tool kbd { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); font: 700 12px/1 'LXGW WenKai TC', sans-serif; background: var(--ink); color: var(--paper);
  padding: 4px 7px; border-radius: 6px; box-shadow: 0 2px 0 #1e150f; white-space: nowrap; }
.tool b { position: absolute; right: -6px; top: -8px; background: var(--accent); color: #fff6e6; font-size: 13px; padding: 2px 7px; border-radius: 10px; }
.tool .regen { position: absolute; left: 10px; right: 10px; bottom: 14px; height: 4px; border-radius: 2px; background: rgba(59, 44, 34, .18); overflow: hidden; }
.tool .regen u { display: block; height: 100%; width: 100%; background: var(--ok); }
.tool.empty { opacity: .65; }
.tool.empty b { background: #8a7a6a; }
body:not(.touch) #hint { max-width: max(320px, calc(100% - 640px)); }
@media (max-height: 600px) { #tools { transform: scale(.85); transform-origin: right bottom; } }

/* 標題卡底部：語言下拉、音效圖示、清除進度（淡色小字） */
#title .tfoot { display: flex; align-items: center; gap: 10px; width: min(300px, 100%); padding-top: 12px; margin-top: 2px; border-top: 1px solid rgba(160, 136, 104, .35); }
.langsel { display: inline-flex; align-items: center; gap: 4px; border: 1.5px solid var(--line); border-radius: 16px; padding: 2px 4px 2px 6px; background: var(--card); cursor: pointer; }
.langsel img { width: 22px; height: 22px; }
.langsel select { font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: 0; outline: 0; cursor: pointer; padding: 2px 2px 2px 0; }
.iconbtn { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; padding: 0; }
.iconbtn img { width: 24px; height: 24px; }
.link { margin-left: auto; border: 0; background: none; padding: 4px 2px; font-size: 13px; color: #9a8672; text-decoration: underline; text-underline-offset: 3px; }

/* 小燈提示：在營地、燈沒開時閃動 */
@keyframes lampPulse { 50% { box-shadow: 0 0 0 4px rgba(246, 194, 126, .9), 0 0 22px rgba(255, 200, 110, .8); transform: scale(1.06); } }

/* ── 世界地圖頁 ── */
.wmap { position: relative; width: 100%; max-width: 920px; margin: 0 auto; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 16px rgba(60, 40, 20, .2); }
.wmap img { display: block; width: 100%; }
.wmap .route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wmap .route polyline { fill: none; stroke: rgba(194, 96, 58, .85); stroke-width: .55; stroke-dasharray: 1.4 1.1; stroke-linecap: round; stroke-linejoin: round; }
.wmap .fog { position: absolute; width: 19%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  backdrop-filter: grayscale(1) blur(3px) brightness(1.08); -webkit-backdrop-filter: grayscale(1) blur(3px) brightness(1.08);
  -webkit-mask: radial-gradient(circle, #000 52%, transparent 71%); mask: radial-gradient(circle, #000 52%, transparent 71%); }
.wn { position: absolute; transform: translate(-50%, -50%); border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: default; }
.wn.ok { cursor: pointer; }
.wn .pin, .wr .pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 14px;
  background: var(--accent); color: #fff6e6; border: 2.5px solid #fff6e6; box-shadow: 0 2px 6px rgba(40, 25, 10, .35); }
.wn.locked .pin, .wr.locked .pin { background: #8a7a6a; font-size: 13px; }
.wn.here .pin { background: #3b2c22; width: 36px; height: 36px; animation: hereBob 1.2s ease-in-out infinite; }
@keyframes hereBob { 50% { transform: translateY(-4px); } }
.wn .lb { background: rgba(251, 245, 232, .94); padding: 2px 8px; border-radius: 8px; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 6px rgba(40, 25, 10, .2); color: var(--ink); line-height: 1.3; text-align: center; }
.wn .lb small { display: block; font-size: 11px; color: var(--ink2); }
.wn.ok:hover .lb { background: #fff; outline: 2px solid var(--accent); }
.wn .hereTag { font-style: normal; font-size: 11px; background: #3b2c22; color: var(--paper); padding: 1px 7px; border-radius: 8px; }
.wlist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 920px; margin: 14px auto 0; }
.wr { display: flex; align-items: center; gap: 8px; background: var(--card); padding: 8px 10px; border-radius: 8px; box-shadow: 0 1px 4px rgba(60, 40, 20, .12); }
.wr .wt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wr .wt b { font-size: 15px; }
.wr .wt span { font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wr .wp { font-size: 13px; color: var(--ink2); }
.wr button { border: 0; background: var(--accent); color: #fff6e6; padding: 5px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.wr button:disabled { background: #b8a890; }
.wr.locked { opacity: .7; }
@media (max-width: 720px) {
  .wn .lb { font-size: 10.5px; padding: 1px 5px; }
  .wn .lb small { display: none; }
  .wn .pin { width: 22px; height: 22px; font-size: 11px; border-width: 2px; }
  .wn.here .pin { width: 26px; height: 26px; }
  .wn .hereTag { display: none; }
  .wlist { grid-template-columns: 1fr; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .wn .lb small { display: none; }
  .wlist { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ═════════════ 顏料島歷險記 ═════════════ */
.area-box { display: flex; flex-direction: column; gap: 3px; }
#hearts { display: flex; gap: 2px; }
#hearts img { width: 26px; height: 26px; }
.row2 { display: flex; align-items: center; gap: 10px; font-size: 15px; }
#areaName { font-weight: 700; font-size: 17px; letter-spacing: .05em; white-space: nowrap; }
.drops, .keys { display: inline-flex; align-items: center; gap: 2px; color: var(--ink2); font-size: 15px; }
.drops img, .keys img { width: 22px; height: 22px; }
.keys b { font-size: 13px; margin-right: 4px; }

#bossbar { position: fixed; top: calc(14px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 11; width: min(420px, calc(100% - 420px)); min-width: 200px; text-align: center; pointer-events: none; }
#bossName { font-size: 17px; font-weight: 700; color: var(--paper); text-shadow: 0 1px 4px rgba(20, 10, 30, .8); letter-spacing: .1em; margin-bottom: 3px; }
#bossbar .bar { height: 14px; border-radius: 8px 3px 9px 4px; background: rgba(30, 22, 40, .7); border: 1.5px solid rgba(239, 230, 210, .8); overflow: hidden; }
#bossbar .bar b { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #8a5ab8, #b8463a); transition: width .25s; }

#prompt { position: fixed; left: 0; top: 0; z-index: 8; pointer-events: none; transform: translate(-50%, -100%); background: rgba(239, 230, 210, .95); border-radius: 14px 14px 14px 4px; padding: 4px 11px 4px 6px; font-size: 15px; white-space: nowrap; box-shadow: 0 3px 10px rgba(50, 30, 15, .25); display: flex; align-items: center; gap: 6px; }
#prompt kbd, .dbox kbd { font: 700 12px/1 'LXGW WenKai TC', sans-serif; background: var(--ink); color: var(--paper); padding: 3px 6px; border-radius: 5px; box-shadow: 0 2px 0 #1e150f; }
body.touch #prompt { padding: 4px 11px; }

/* 對話框 */
#dlg { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--sa-b)); z-index: 24; display: flex; justify-content: center; padding: 0 16px; }
.dbox { position: relative; width: min(760px, 100%); background: rgba(250, 244, 230, .97); border: 2px solid var(--line); border-radius: 8px 22px 10px 24px / 22px 8px 24px 10px; box-shadow: var(--shadow); padding: 18px 22px 18px; min-height: 108px; cursor: pointer; }
#dlgName { position: absolute; top: -16px; left: 22px; background: var(--accent); color: #fff6e6; font-weight: 700; padding: 4px 14px; border-radius: 6px 14px 6px 14px; font-size: 16px; box-shadow: 0 3px 0 var(--accent-d); }
#dlgText { font-size: 18.5px; line-height: 1.7; color: var(--ink); min-height: 3.4em; white-space: pre-line; }
#dlgMore { position: absolute; right: 18px; bottom: 8px; color: var(--accent); animation: bob 0.9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
#dlgChoices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
#dlgChoices:empty { display: none; }
#dlgChoices button { border: 1.5px solid var(--line); background: var(--card); border-radius: 14px 6px 14px 6px; padding: 7px 14px; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 3px 0 var(--line); }
#dlgChoices button:hover { background: #fbe3b0; }
body.touch #dlgChoices kbd { display: none; }
@media (orientation: portrait) { body.touch #dlg { bottom: calc(214px + var(--sa-b)); } }
@media (orientation: landscape) and (max-height: 540px) {
  #dlg { bottom: calc(8px + var(--sa-b)); padding: 0 200px 0 150px; }
  .dbox { padding: 14px 16px 12px; min-height: 0; }
  #dlgText { font-size: 15.5px; line-height: 1.55; min-height: 0; }
  #hearts img { width: 21px; height: 21px; }
  .row2 { font-size: 13px; gap: 8px; }
  #areaName { font-size: 14px; }
  #bossbar { width: 300px; top: calc(8px + var(--sa-t)); }
  #bossName { font-size: 14px; }
}

/* 倒下 */
#death { position: fixed; inset: 0; z-index: 22; display: grid; place-content: center; text-align: center; pointer-events: none; opacity: 0; transition: opacity .8s; background: radial-gradient(ellipse, rgba(40, 28, 20, .15), rgba(40, 28, 20, .55)); }
#death.on { opacity: 1; }
#deathT { font-size: clamp(26px, 6vw, 46px); font-weight: 700; color: var(--paper); text-shadow: 0 2px 14px rgba(20, 10, 5, .8); padding: 0 16px; }
#deathS { font-size: 18px; color: var(--paper); opacity: .85; margin-top: 8px; }

/* 結局 */
#ending { position: fixed; inset: 0; z-index: 31; background: rgba(40, 28, 20, .45); display: grid; place-items: center; padding: calc(16px + var(--sa-t)) 16px calc(16px + var(--sa-b)); overflow-y: auto; }
.esheet { background: var(--paper); width: min(620px, 100%); border-radius: 6px 18px 8px 22px / 18px 6px 22px 8px; border: 1.5px solid var(--line); box-shadow: var(--shadow); padding: 24px 28px 18px; text-align: center; }
.esheet img { width: 160px; height: 160px; border-radius: 16px; transform: rotate(-2deg); box-shadow: 0 4px 14px rgba(60, 40, 20, .2); }
.esheet h2 { margin: 12px 0 6px; font-size: 32px; letter-spacing: .1em; }
.esheet p { margin: 0 0 10px; color: var(--ink2); font-size: 16.5px; line-height: 1.7; }
.esheet .stats { color: var(--accent); font-size: 15px; }
.esheet .thanks { color: var(--ink); font-weight: 700; }
.eact { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 8px; }
.credit { font-size: 12.5px; color: #9a8672; margin: 4px 0 0; }
@media (orientation: landscape) and (max-height: 540px) {
  .esheet { display: grid; grid-template-columns: 130px 1fr; gap: 0 16px; text-align: left; padding: 12px 18px; }
  .esheet img { width: 120px; height: 120px; grid-row: span 6; }
  .esheet h2 { font-size: 22px; margin: 0 0 4px; }
  .esheet p { font-size: 13.5px; line-height: 1.5; margin-bottom: 6px; }
  .eact { justify-content: flex-start; }
}

/* 電腦版動作卡 */
.tool.main { width: 96px; background: var(--accent); border-color: var(--accent-d); }
.tool.main .tl { color: #fff6e6; font-weight: 700; }
.tool.main.fire { box-shadow: 0 0 22px rgba(255, 150, 60, .9), var(--shadow); }
#kAct { opacity: .55; }
#kAct.on { opacity: 1; background: #fbe3b0; border-color: var(--gold); animation: actPulse 1.2s ease-in-out infinite; }
#kShd.on { background: #e8d2a0; }

/* 圖例 */
.lg-easel { background: #5f9a4a; border-radius: 3px !important; }
.lg-house { background: #96503c; border-radius: 2px !important; }
.lg-door { background: #d9a63e; border-radius: 1px !important; }
.lg-chest { background: #d9a63e; border: 1.5px solid #5a3a26; border-radius: 2px !important; }
.lg-boss { background: #3a3450; }
#title .credit { margin-top: 4px; }

/* 手機直式：頭目血條移到操作區上方，不跟頂端按鈕重疊 */
@media (max-width: 720px) and (orientation: portrait) {
  #bossbar { top: auto; bottom: calc(222px + var(--sa-b)); width: calc(100% - 40px); }
}

/* ── 目前目標：HUD 一行字＋目標頭上的星星＋畫面邊緣的金色指標 ── */
#goal { display: flex; align-items: flex-start; gap: 6px; max-width: min(300px, 58vw); background: rgba(239, 230, 210, .92); padding: 5px 11px 6px 6px;
  border-radius: 10px 4px 12px 6px; box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.35; color: var(--ink); pointer-events: none; }
#goal img { width: 26px; height: 26px; flex: none; margin-top: 1px; }
#goal b { display: block; font-size: 11.5px; color: var(--accent); letter-spacing: .06em; }
#goal.new { animation: goalPulse .65s ease-in-out 4; }
@keyframes goalPulse { 50% { transform: scale(1.04); box-shadow: 0 0 0 3px rgba(224, 176, 74, .75), var(--shadow); } }
#goalTag { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; display: flex; align-items: center; gap: 4px; background: rgba(58, 44, 34, .84); color: #ffe2a0;
  padding: 3px 10px 3px 4px; border-radius: 12px; font-size: 13.5px; white-space: nowrap; box-shadow: 0 3px 10px rgba(30, 20, 10, .25); }
#goalTag img { width: 22px; height: 22px; }
#pointers .ptr img { display: none; width: 20px; height: 20px; margin: -2px -2px -2px 0; }
#pointers .ptr.goal { background: rgba(120, 78, 30, .9); color: #ffe9b8; z-index: 8; }
#pointers .ptr.goal img { display: block; }
#pointers .ptr.goal i { border-left-color: #ffd36a; }
#exitTags > div.goal { background: rgba(120, 78, 30, .9); color: #ffe9b8; box-shadow: 0 0 0 2px rgba(255, 211, 106, .8); }
.lg-goal { background: #f2c14e; border: 1.5px solid #6a4a1a; transform: rotate(45deg) scale(.9); border-radius: 2px !important; }
@media (orientation: landscape) and (max-height: 540px) {
  #goal { font-size: 12px; padding: 3px 9px 4px 5px; max-width: 34vw; }
  #goal img { width: 20px; height: 20px; }
  #goal b { font-size: 10.5px; }
}
@media (max-width: 720px) and (orientation: portrait) {
  #goal { font-size: 12.5px; max-width: 62vw; }
  #goal img { width: 22px; height: 22px; }
}
