:root {
  --bg: #05070d;
  --panel: rgba(14, 20, 32, 0.88);
  --line: rgba(140, 190, 255, 0.25);
  --text: #e8eef8;
  --dim: #8fa0b8;
  --accent: #5fd0ff;
  --warn: #ff6b4a;
  --good: #7ee08a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif; -webkit-tap-highlight-color: transparent; }
/* 不讓瀏覽器自己縮放（雙擊、雙指）：有些手機會無視 viewport 的 user-scalable=no，要在觸控層再擋一次；縮放用遊戲自己的 －／＋ */
html, body, #ui, #ui * { touch-action: pan-x pan-y; }
#view { position: fixed; inset: 0; touch-action: none; }
#view canvas { display: block; }
/* 介面層預設不擋點擊（點擊要穿透到 3D 畫面）；只有真的要互動的面板打開 */
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen, .bag, .panel, .hud button, .dock-card { pointer-events: auto; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

/* 全螢幕面板 */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 28%, #5a3c1c 0%, #2a1a0c 45%, #120a04 80%); padding: 16px; }
.card { width: min(420px, 100%); background: rgba(38, 24, 12, .88); border: 1px solid #6a4a28; border-radius: 14px; padding: 24px; text-align: center; color: #f0e2c8; }
.card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 2px; color: #f2d8a8; }
.card p { color: #c8b08c; margin: 6px 0 18px; line-height: 1.6; }
.card .primary { background: #d8a860; color: #2a1806; }
.card .primary:disabled { background: #5a4630; color: #a8906c; }
.recovery-card .code { margin: 10px 0; padding: 10px; border-radius: 8px; background: rgba(0, 0, 0, .35); font: 600 17px/1.5 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; text-align: center; user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }
.card .linkish { background: none; border: 0; color: #e0b070; font-size: 14px; letter-spacing: 2px; margin-top: 12px; padding: 4px 8px; cursor: pointer; }
.card p.msg { color: #ff8a6a; font-size: 13px; margin: 6px 0; min-height: 1em; }
.card .restore-code { font-family: ui-monospace, Menlo, Consolas, monospace; text-align: center; }
.card .forum-link { display: inline-block; margin-top: 12px; color: #e0b070; font-size: 14px; text-decoration: none; letter-spacing: 2px; }
.card.home .sub { margin: -6px 0 14px; color: #e0b070; letter-spacing: 6px; font-size: 15px; }
.card.home h1 { font-size: 44px; letter-spacing: 12px; margin: 6px 0 10px; text-shadow: 0 2px 0 #6a3a14; }
.card .records li { border-bottom-color: rgba(216, 168, 96, .12); }
.card .records li b { color: #e0b070; }
.card .records h3, .card .records li::before { color: #a8906c; }
.card input { width: 100%; font-size: 18px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0b1220; color: var(--text); text-align: center; }
.card .steps { text-align: left; color: var(--text); background: #0b1220; border-radius: 8px; padding: 10px 14px; }
.primary { width: 100%; padding: 12px; font-size: 18px; border: 0; border-radius: 10px; background: var(--accent); color: #04111c; font-weight: 700; }
.primary:disabled { background: #33414f; color: #7c8a99; cursor: default; }
.secondary { width: 100%; padding: 10px; margin-top: 8px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 18px; }
.stats div { background: #0b1220; border-radius: 8px; padding: 10px; }
.stats b { display: block; font-size: 22px; }
.stats small { color: var(--dim); }
.records { margin-top: 18px; text-align: left; }
.records h3 { margin: 0 0 6px; font-size: 14px; color: var(--dim); font-weight: 500; text-align: center; letter-spacing: 1px; }
.records ol { margin: 0; padding: 0; list-style: none; counter-reset: r; max-height: 30vh; overflow-y: auto; }
.records li { counter-increment: r; display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 14px; border-bottom: 1px solid rgba(140, 190, 255, .08); }
.records li::before { content: counter(r); width: 18px; color: var(--dim); font-size: 12px; text-align: right; }
.records li i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.records li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records li b { font-weight: 500; color: var(--accent); font-size: 13px; white-space: nowrap; }

/* 提示與吐司 */
.hint { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--line); font-size: 15px; text-align: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
/* --top-h＝上方狀態列／提示實際的高度（ui.js 量），吐司排在它下面才不會蓋住 */
.toasts { position: absolute; top: calc(max(var(--top-h, 0px), env(safe-area-inset-top)) + 8px); left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 2; }
.toast { max-width: 100%; text-align: center; padding: 6px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); font-size: 15px; transition: opacity .5s, transform .5s; }
.toast.good { color: var(--good); }
.toast.bad { color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(-10px); }
.fade { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.glare { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 2s; mix-blend-mode: screen;
  background: radial-gradient(ellipse 120% 70% at 50% -10%, rgba(255, 250, 225, .55), rgba(255, 238, 200, .18) 45%, transparent 75%); }
.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1s;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(2, 4, 12, .85) 100%); }
.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(255, 40, 30, .8); }
.flash.on { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud button { pointer-events: auto; }
/* 上方狀態列：左＝血條／三數值／動靜（都可換行，窄螢幕不會撐出畫面），右＝時鐘 */
.hud-top { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); right: calc(10px + env(safe-area-inset-right));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.vitals { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.vstats { display: flex; flex-wrap: wrap; gap: 5px; }
.stat { display: flex; align-items: center; gap: 4px; font-size: 13px; padding: 2px 6px 2px 4px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.mini { position: relative; width: clamp(28px, 8vw, 44px); height: 7px; border-radius: 4px; background: #1a2230; overflow: hidden; }
.mini i { position: absolute; inset: 0 auto 0 0; transition: width .3s; }
.hunger .mini i { background: #f2a64e; }
.thirst .mini i { background: #4eb4f2; }
.energy .mini i, .mini.energy i { background: #b48cff; }
.mini.hp i { background: #ff6b5a; }
.stat.low { border-color: var(--warn); animation: statBlink .7s infinite alternate; }
.stat.empty { border-color: #ff5040; animation: statEmpty .5s infinite alternate; }
@keyframes statBlink { to { background: #5a3a10; box-shadow: 0 0 8px var(--warn); } }
@keyframes statEmpty { to { background: #7a1a10; box-shadow: 0 0 10px #ff5040; } }
.vwarn { font-size: 13px; font-weight: 700; color: #ff8070; text-shadow: 0 1px 2px #000; animation: pulse .6s infinite alternate; }
.bar { position: relative; width: min(220px, 100%); height: 22px; border-radius: 11px; background: #1a2230; border: 1px solid var(--line); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff7d6b, #d8392a); transition: width .2s; }
.bar.weak i { background: linear-gradient(#8a1a1a, #4a0808); opacity: .6; transition: none; }
.bar.weak { animation: weakPulse 1.6s ease-in-out infinite; }
@keyframes weakPulse { 50% { box-shadow: 0 0 10px #a01010; } }
.bar.low i { animation: pulse .8s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.6); } }
.bar span { position: relative; display: block; text-align: center; font-size: 13px; line-height: 20px; text-shadow: 0 1px 2px #000; }
.clock { flex-shrink: 0; padding: 4px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.clock.night { color: #b8a8ff; border-color: rgba(160, 130, 255, .5); }
.hud-bottom { position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; }
.hud-bottom button { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 28px; position: relative; color: var(--text); }
.hud-bottom .btn-act { width: 78px; height: 78px; font-size: 34px; }
.hud-bottom button .icon { width: 30px; height: 30px; vertical-align: middle; }
.hud-bottom .btn-act .icon { width: 44px; height: 44px; }
.btn-mute .icon { width: 20px; height: 20px; vertical-align: middle; }
.stat .icon { width: 16px; height: 16px; flex-shrink: 0; }
.hud-bottom .btn-build, .hud-bottom .btn-do { width: 54px; height: 54px; font-size: 24px; }

/* 鏡頭旋轉：右下按鈕列的上方，不和面板抽屜（中下／橫拿靠左）打架 */
.hud-view { position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(108px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; }
.hud-view .btn-zoom { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 20px; line-height: 1; padding: 0; }
.btn-fs, .btn-mute, .btn-menu { flex-shrink: 0; width: 32px; height: 28px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; line-height: 1; }
.btn-fs.on { color: var(--accent); }
.hud-view .btn-rot { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 22px; line-height: 1; }
.compass { cursor: pointer; width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; justify-content: center; } /* 是按鈕：HUD 只有按鈕接得到點擊 */
.compass i { font-style: normal; font-size: 12px; font-weight: 700; color: var(--warn); display: block; transition: transform .15s linear; }
/* 觸控搖桿 */
.joy { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(10, 16, 28, .25); pointer-events: none; }
.joy i { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255, 255, 255, .55); }
.btn-bag .count { position: absolute; right: -2px; top: -2px; min-width: 22px; padding: 0 5px; height: 22px; border-radius: 11px; background: var(--accent); color: #04111c; font-size: 12px; line-height: 22px; }

/* 抽屜：背包／情境面板／降落點面板都排在這一欄，彼此不疊；超出就在抽屜裡捲。
   手機直拿＝下方、在按鈕列上面；手機橫拿＝靠左（右下是按鈕）；大螢幕＝下方置中。
   抽屜只有內容那麼高（貼底、max-height 封頂），所以抽屜本身可以接手指（捲動一定捲得動），又不會擋到上面的 3D 畫面。
   --db＝抽屜底離畫面底多遠（各種版面不同），max-height 由它和上方 HUD 的高度（--top-h，ui.js relayout 量）算出。
   面板打開時鏡頭會把角色移到沒被擋住的那塊（ui.js relayout → engine fitCamera） */
.drawer { --db: calc(12px + env(safe-area-inset-bottom));
  position: absolute; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 24px));
  bottom: var(--db); max-height: calc(100% - var(--top-h, 0px) - 10px - var(--db));
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; pointer-events: auto; }
.hud:not(.hidden) ~ .drawer { --db: calc(164px + env(safe-area-inset-bottom)); } /* 讓出右下按鈕列＋鏡頭列 */
/* 電腦：貼底，擺在右下按鈕列（約 370px）的左邊，不蓋到按鈕 */
@media (min-width: 1000px) and (min-height: 601px) { .hud:not(.hidden) ~ .drawer { --db: calc(16px + env(safe-area-inset-bottom)); left: auto; right: calc(390px + env(safe-area-inset-right)); transform: none; width: min(420px, calc(100vw - 410px)); } }
@media (orientation: landscape) and (max-height: 600px) {
  .drawer, .hud:not(.hidden) ~ .drawer { --db: calc(10px + env(safe-area-inset-bottom)); left: calc(10px + env(safe-area-inset-left)); transform: none; width: min(380px, 46vw); }
}
.drawer > * { flex-shrink: 0; }
/* 下面還有東西：抽屜底部一條提示（捲到底就消失） */
.drawer.more::after { content: '▼ 往下滑還有'; position: sticky; bottom: 0; flex-shrink: 0; margin-top: -30px; height: 30px; line-height: 34px; text-align: center; font-size: 12px; color: var(--text);
  background: linear-gradient(transparent, rgba(5, 7, 13, .92)); border-radius: 0 0 14px 14px; pointer-events: none; }

/* 背包 */
.bag { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.bag-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 700; position: sticky; top: 0; z-index: 3; background: inherit; }
.bag-head small { color: var(--dim); font-weight: 400; }
.bag-head .close { margin-left: auto; background: none; border: 0; color: var(--dim); font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 58px)); justify-content: center; gap: 6px; }
.slot { aspect-ratio: 1; border-radius: 8px; background: #0b1220; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 26px; position: relative; color: var(--text); padding: 0; }
button.slot:hover { border-color: var(--accent); }
.slot b { position: absolute; right: 4px; bottom: 2px; font-size: 12px; }
.slot .gm { position: absolute; left: 4px; top: 2px; font-size: 10px; font-style: normal; color: #ffd27a; }
.affix { white-space: nowrap; font-size: 12px; }
.affix.good { color: #7fdc8a; }
.affix.bad { color: #ff8a7a; }
.slot.empty { opacity: .45; }
.belt-label { font-size: 13px; font-weight: 700; margin: 2px 0 6px; }
.belt-label small { color: var(--dim); font-weight: 400; margin-left: 6px; }
.grid.belt { margin-bottom: 12px; padding: 6px; border-radius: 10px; background: rgba(160, 112, 60, .14); border: 1px solid rgba(200, 150, 90, .35); } /* 腰帶：皮帶色 */
.bag-head .move { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; font-size: 16px; padding: 2px 10px; }
.bag-head .move.on { background: var(--accent); color: #04111c; border-color: var(--accent); }
.slot.movable { border-color: var(--accent); animation: wiggle .6s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }

/* 下方情境面板：建造／放置／營火／帳篷 */
.dock:not(.on) { display: none; }
.dock-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.dock-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: -12px -12px 10px; padding: 12px 12px 6px; position: sticky; top: 0; z-index: 3; background: inherit; border-radius: 14px 14px 0 0; } /* 關閉鈕固定在頂上，不會跟著捲走 */
.dock-head small { color: var(--dim); font-weight: 400; font-size: 13px; }
.dock-head .close { margin-left: auto; background: none; border: 0; color: var(--dim); font-size: 18px; }
.recipes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recipe { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 8px; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: #0b1220; color: var(--text); }
.recipe .ricon { grid-row: 1 / 4; font-size: 30px; align-self: center; }
.recipe small { color: var(--dim); font-size: 12px; }
.recipe .cost { font-size: 12px; color: var(--good); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.recipe .cost .short { color: var(--warn); }
.recipe .ricon .icon { width: 30px; height: 30px; }
.dock-sub { margin: 12px 0 8px; font-weight: 700; }
.dock-sub small { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 6px; }
.chest-card .label { font-size: 12px; color: var(--dim); text-align: center; margin-top: 8px; line-height: 1.5; }
.recipe.off { cursor: default; }
.recipe:not(:disabled):hover { border-color: var(--accent); }
.place { display: flex; align-items: center; gap: 10px; }
.place .ricon { font-size: 30px; }
.ptext { flex: 1; display: flex; flex-direction: column; }
.ptext small { font-size: 13px; }
.ptext .good { color: var(--good); }
.ptext .bad { color: var(--warn); }
.place button { width: 52px; height: 52px; border-radius: 50%; font-size: 22px; border: 1px solid var(--line); background: #0b1220; color: var(--text); }
.place .ok { background: var(--accent); color: #04111c; border: 0; font-weight: 700; }
.place .ok:disabled { background: #33414f; color: #7c8a99; }
.place .steps { display: flex; flex-direction: column; gap: 4px; }
.place .steps button { width: 44px; height: 24px; border-radius: 8px; font-size: 13px; }

/* 演奏面板：上面挑樂器、✕ 清掉、⏹ 收起來；下面是珠子（canvas） */
.music .dock-head { display: flex; align-items: center; justify-content: space-between; }
.music .insts { display: flex; gap: 6px; }
.music .dock-head button { min-width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #0b1220; color: var(--text); font-size: 18px; }
.music .dock-head .inst.on { border-color: var(--accent); background: rgba(95,208,255,.15); }
.music .dock-head .inst .icon { width: 26px; height: 26px; }
.music .dock-head .wipe { margin-right: 6px; }
.music canvas.beads { display: block; width: 100%; margin-top: 8px; border-radius: 10px; touch-action: none; }

/* 商人：一筆交換一列「你給的（紅框）➜ 你拿到的（綠框）」 */
.mirage-card .trades li.trow.deal { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 56px; align-items: center; gap: 6px; padding: 6px 2px; }
.mirage-card .trow .tchip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; box-sizing: border-box; width: 100%; padding: 4px 6px; border-radius: 10px; border: 1px solid; }
.mirage-card .trow .tchip.give { border-color: rgba(255,138,106,.55); background: rgba(255,138,106,.08); }
.mirage-card .trow .tchip.get { border-color: rgba(126,224,138,.55); background: rgba(126,224,138,.08); }
.mirage-card .trow .tchip b { font-size: 15px; white-space: nowrap; margin: 0; }
.mirage-card .trow .tchip small { max-width: 100%; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mirage-card .trow .tchip .tl { display: flex; align-items: center; gap: 4px; }
.mirage-card .deal .arrow { color: var(--dim); font-size: 16px; }
.mirage-card .deal button { min-width: 52px; height: 40px; border-radius: 10px; border: 0; background: var(--accent); color: #04111c; font-weight: 700; }
.mirage-card .deal button:disabled { background: #33414f; color: #7c8a99; }
.mirage-card .deal .taff { grid-column: 1 / -1; margin: 0 0 0 4px; }

/* 營火：上＝鐵網烤架（食材），中＝火焰，下＝石頭爐床（柴火） */
.fire-card { background: linear-gradient(#1a1410 0%, #120d0a 100%); border-color: rgba(255, 150, 60, .35); }
.fire-card .row { display: grid; grid-template-columns: repeat(4, minmax(0, 60px)); justify-content: center; gap: 8px; }
.fire-card .fslot { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.fuelbar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .4); overflow: hidden; margin-bottom: 8px; }
.fuelbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff9a3a, #ffd060); }
.fuelbtns { display: flex; gap: 8px; }
.addother { flex: 0 0 auto; padding: 10px 12px; font-size: 15px; border-radius: 10px; border: 1px solid #7a5230; background: #2a1a10; color: #f3e6d8; }
.addother:disabled { opacity: .45; }
.addwood { flex: 1; width: 100%; padding: 10px; font-size: 16px; border-radius: 10px; border: 1px solid #7a5230; background: #3a2414; color: #f3e6d8; }
.addwood:disabled { opacity: .45; }
.fire-card .label { font-size: 12px; color: #b39a82; text-align: center; margin-top: 6px; }
/* 火裡：沒有鍋，東西直接埋在炭火上 */
.coals { padding: 10px; border-radius: 10px; border: 1px solid #5a3a28;
  background: radial-gradient(circle at 20% 80%, rgba(255, 110, 40, .35) 0 6px, transparent 14px),
    radial-gradient(circle at 70% 75%, rgba(255, 140, 50, .3) 0 5px, transparent 12px),
    radial-gradient(circle at 45% 90%, rgba(255, 90, 30, .3) 0 7px, transparent 16px),
    linear-gradient(#2a1a12, #3a2116); }
.icon { width: 1.3em; height: 1.3em; vertical-align: -0.3em; }
.slot .icon, .fslot .icon { width: 62%; height: 62%; }
.fslot .ic { display: contents; }
.fslot.burning { border: 1px solid #ff5a3a; animation: pulse .5s infinite alternate; }
.fslot.burning .prog { background: linear-gradient(90deg, #ff7a3a, #d0201a); }
.fslot.ashed { border-style: solid; border-color: #6a6866; }
.hearth { padding: 10px; border-radius: 10px; background: radial-gradient(ellipse at 50% 0%, #4a2a18 0%, #1e1612 70%); border: 1px solid #4a3d33; }
.fslot { position: relative; aspect-ratio: 1; border-radius: 8px; border: 1px dashed #6b5a4c; background: rgba(0, 0, 0, .35); color: #f3e6d8; font-size: 28px; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0; }
.fslot:hover { border-color: #ffb060; }
.fslot b { position: absolute; right: 4px; bottom: 2px; font-size: 11px; }
.fslot .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, #ffb060, #ff6030); width: 0; }
.fslot.done { border: 1px solid var(--good); box-shadow: inset 0 0 12px rgba(126, 224, 138, .35); }
.flames { height: 30px; margin: 4px 0; display: flex; justify-content: space-around; align-items: flex-end; }
.flames span { width: 22px; height: 30px; border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 80%, #fff3b0 0%, #ffb040 35%, #ff5a1f 70%, transparent 72%);
  animation: flick 0.6s ease-in-out infinite alternate; transform-origin: 50% 100%; filter: drop-shadow(0 0 6px #ff7a2a); }
.flames span:nth-child(2n) { animation-duration: .45s; height: 24px; }
.flames span:nth-child(3n) { animation-duration: .7s; height: 34px; }
@keyframes flick { from { transform: scaleY(.8) scaleX(1.05); opacity: .85; } to { transform: scaleY(1.1) scaleX(.9); opacity: 1; } }
.fire-card.out .flames span { animation: none; background: radial-gradient(ellipse at 50% 90%, #6b4a3a 0%, #3a2a22 60%, transparent 62%); filter: none; height: 10px; }
.fire-card.out .fire-state { color: var(--warn); }

/* 帳篷 */
.mini.big { width: 100%; height: 10px; margin-top: 4px; }

/* 降落點面板 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.panel h2 { margin: 0 0 6px; font-size: 20px; }
.panel .row { display: flex; justify-content: space-between; color: var(--dim); margin: 4px 0; font-size: 14px; }
.panel .row b { color: var(--text); font-weight: 500; }
.panel .row b.bad { color: var(--warn); }
.panel .row b.good { color: var(--good); }
.panel .tents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.panel .tents button { width: auto; flex: 1; margin: 0; font-size: 13px; padding: 8px; }
.panel .tents button.on { border-color: #ffb04a; color: #ffd88a; }
.panel .btns { display: flex; gap: 8px; margin-top: 12px; }
.panel .btns button { flex: 1; margin: 0; }

/* 確認視窗 */
.confirm-card p { margin: 0 0 12px; line-height: 1.6; text-align: center; }
.confirm-card .btns { display: flex; gap: 8px; position: sticky; bottom: 0; padding-top: 8px; background: var(--panel); } /* 字很多要捲的時候，按鈕永遠看得到 */
.confirm-card .btns button { flex: 1; margin: 0; }

/* 靈光護盾按鈕：開著發光、冷卻時從上往下蓋一層暗色（剩多少冷卻蓋多少） */
.hud-bottom .btn-shield { overflow: hidden; border-color: rgba(143, 232, 255, .6); }
.btn-shield span { position: relative; z-index: 1; }
.btn-shield .cd { position: absolute; left: 0; right: 0; top: 0; height: 0; background: rgba(0, 0, 0, .55); pointer-events: none; }
.btn-shield.on { background: rgba(143, 232, 255, .55); box-shadow: 0 0 18px rgba(143, 232, 255, .9); }
.btn-shield.cooling span { opacity: .5; }
.btn-shield.parry { background: rgba(255, 226, 140, .7); box-shadow: 0 0 20px rgba(255, 220, 120, .95); }

/* 求生日誌 */
/* 右上：時鐘在上、小按鈕一排在下（窄螢幕也不擠左邊的血條） */
.hud-top .tr { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.hud-top .tbtns { display: flex; gap: 5px; }

/* 熔爐 */
.furnace-card { background: linear-gradient(#1c1612, #14100d); border-color: rgba(255, 150, 60, .3); }
.frow { display: flex; align-items: center; gap: 8px; justify-content: center; }
.fcell { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 58px; background: none; border: 0; padding: 0; color: var(--text); }
.fcell .slot { width: 52px; }
.fcell small { font-size: 11px; color: var(--dim); white-space: nowrap; }
.fcell.out small { color: var(--good); }
.farrow { position: relative; width: 44px; height: 18px; text-align: center; color: var(--dim); border-radius: 9px; background: #0b1220; overflow: hidden; font-size: 13px; line-height: 18px; }
.farrow .fprog { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #ffb060, #ff6030); opacity: .7; }
.tlots { list-style: none; margin: 0 0 8px; padding: 0; }
.tlots li { display: flex; align-items: center; gap: 6px; padding: 4px 2px; font-size: 14px; }
.tlots li small { margin-left: auto; color: var(--dim); }
.tan-card .ttake { width: 100%; }
.furnace-card .label { font-size: 12px; color: #b39a82; text-align: center; margin-top: 8px; line-height: 1.5; }

/* 小地圖：右上角，點一下放大 */
.minimap { width: 96px; height: 96px; border-radius: 50%; border: 1px solid var(--line); background: #05070d; pointer-events: auto; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.minimap.big { width: 176px; height: 176px; }

/* 太空船上：只留血條（和搖桿） */
.hud.intro .vstats, .hud.intro .tr, .hud.intro .hud-bottom, .hud.intro .hud-view { display: none; }
.hint.below-hud { top: calc(44px + env(safe-area-inset-top)); }

/* 環境危險提示 */
.hazard { max-width: 100%; padding: 3px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.hazard.miasma, .hazard.toxin { color: #9fe07a; border-color: rgba(120, 220, 90, .6); }
.hazard.cold { color: #a8d8ff; border-color: rgba(160, 210, 255, .6); }
.hazard.heat { color: #ffc070; border-color: rgba(255, 180, 90, .6); }
/* 地城：沒有建造、沒有動靜；上方中間是首領血條，左上多一行「這一趟帶著什麼」 */
.hud.dungeon .btn-build { display: none; }
.runloot { max-width: 100%; padding: 3px 10px; border-radius: 12px; background: var(--panel); border: 1px solid rgba(255, 90, 60, .5); font-size: 13px; }
.runloot .icon { width: 16px; height: 16px; vertical-align: -3px; }
.bossbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); width: min(78vw, 420px); text-align: center; pointer-events: none; }
.bossbar b { display: block; font-size: 14px; color: #ffd0c0; text-shadow: 0 1px 3px #000; letter-spacing: 2px; }
.bossbar .bb { height: 10px; margin-top: 3px; border-radius: 5px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 90, 60, .7); overflow: hidden; }
.bossbar .bb i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff3a2a, #ff8a4a); transition: width .15s; }
.bossbar.stunned .bb i { background: linear-gradient(90deg, #fff27a, #ffc830); }
.vignette.locked { background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(140, 10, 10, .85) 100%); opacity: .95 !important; }
.hazard.fire { color: #ffb070; border-color: rgba(255, 120, 40, .8); }
.hazard.sand { color: #f2d0a0; border-color: rgba(220, 170, 100, .7); }
.hazard.locked { color: #ff8a7a; border-color: rgba(255, 90, 70, .7); }
.vignette.toxic { background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(40, 110, 20, .8) 100%); opacity: .9 !important; }
/* 技能 */
.skills { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.skills li { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.skills li small { color: var(--dim); font-size: 11px; }
.skills .mini i { background: var(--accent); }

/* 交易箱 */
.market-card .offer { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(140, 190, 255, .1); }
.market-card .offer > div { flex: 1; min-width: 0; line-height: 1.6; }
.market-card .offer .buy { width: 64px; padding: 8px; font-size: 15px; }
.market-card .mi { white-space: nowrap; }
.market-card .mi .icon { width: 1.4em; height: 1.4em; }
.market-card small.good { color: var(--good); }
.market-card small.bad { color: var(--warn); }
.market-card .dim { color: var(--dim); }
.market-card .orow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0; font-size: 13px; }
.market-card .orow select { max-width: 96px; font: inherit; background: #0b1220; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.market-card .orow input { width: 44px; font: inherit; background: #0b1220; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px; text-align: center; }
.market-card .orow .ref { width: 100%; font-size: 11px; }
.mgrid { grid-template-columns: repeat(6, minmax(0, 48px)); }

/* 換區的大字、換圈的小字：不擋點擊 */
.zonetitle { position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1.1s; z-index: 3; }
.zonetitle.show { opacity: 1; transition: opacity .8s; }
.zonetitle b { display: block; font-size: clamp(26px, 8vw, 44px); letter-spacing: .3em; color: #f2e8d8; text-shadow: 0 2px 12px rgba(0, 0, 0, .9); font-weight: 600; }
.zonetitle small { display: block; margin-top: 8px; font-size: 14px; letter-spacing: .15em; color: #cfc2ae; text-shadow: 0 1px 6px #000; }

/* 創角：往哪裡爬出去 */

/* 蜃人的聚落 */
.mirage-card .say { margin: 0 0 8px; color: #cfc2ae; font-style: italic; }
.trades { list-style: none; margin: 0; padding: 0; }
.trades li { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid rgba(140, 190, 255, .08); }
.trades li span { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.trades li small { color: var(--dim); font-size: 12px; }
.trades li .icon { width: 20px; height: 20px; vertical-align: -5px; }
.trades li button { min-width: 52px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #13213a; color: var(--text); }
.trades li button:disabled { opacity: .4; }

/* ☰ 選單、商會 */
.menu-card .menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 12px; margin-top: 8px; font-size: 16px; text-align: left;
  color: var(--text); background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 10px; }
.menu-card .menu-item small { margin-left: auto; color: var(--dim); font-size: 13px; }
.guild-card .guilds { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.guild-card .guilds li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.guild-card .guilds li b { flex: 1; font-size: 16px; letter-spacing: 1px; overflow-wrap: anywhere; }
.guild-card .guild-join { display: flex; gap: 6px; margin-bottom: 8px; }
.guild-card .guild-join input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 8px 10px; background: #0b1220; color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.guild-pick { display: flex; flex-wrap: wrap; gap: 8px; }

/* 建造選單：頁籤 */
.build-card .tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.build-card .tab { flex: 1; min-width: 0; padding: 7px 2px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; color: var(--dim); font-size: 13px; white-space: nowrap; }
.build-card .tab small { margin-left: 3px; opacity: .7; }
.build-card .tab.on { background: #1d2b44; color: var(--text); border-color: #4a6a9a; }
.btn-build.new { position: relative; }
.btn-build.new::after { content: ''; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #ffd24a; }
/* 新配方：卡片、頁籤右上角的黃點（做過一次或長按看過才消失） */
.recipe, .build-card .tab { position: relative; }
.recipe.fresh::after, .build-card .tab.fresh::after { content: ''; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: #ffd24a; }
.recipe.off { opacity: .5; }

/* 長按道具：名稱和說明 */
.ii { display: contents; } /* 只是標記（長按找得到是哪個道具），版面照舊 */
.itemtip { position: fixed; z-index: 60; max-width: min(280px, 80vw); padding: 8px 10px; border-radius: 10px; background: #0b1220f0; border: 1px solid #4a6a9a; color: var(--text); pointer-events: none; box-shadow: 0 4px 16px #0008; }
.itemtip b { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.itemtip b .icon { width: 24px; height: 24px; }
.itemtip small { display: block; margin-top: 4px; color: var(--dim); font-size: 13px; line-height: 1.4; }
.itemtip.hidden { display: none; }

.vignette.ingrass { background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(30, 50, 12, .7) 100%); opacity: .9 !important; }
.mirage-card .trades .price { flex: none; display: inline-flex; align-items: center; gap: 2px; margin-left: auto; margin-right: 8px; white-space: nowrap; font-size: 13px; } /* 不讓詞條擠掉價錢 */
.mirage-card .trades li span small .affix { margin-right: 6px; }
.mirage-card .trades li.sold { opacity: .55; }
.mirage-card .house { width: 100%; margin: 4px 0 6px; display: flex; justify-content: center; gap: 8px; align-items: baseline; }
.mirage-card .house small { opacity: .8; font-weight: 400; }
.vignette.forbid { background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(190, 230, 255, .6) 100%); opacity: .9 !important; animation: weakPulse 1.2s ease-in-out infinite; }
.bank-card .tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.bank-card .tab { flex: 1; min-width: 0; padding: 6px 4px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bank-card .tab.on { background: #1d2b44; color: var(--text); border-color: #4a6a9a; }
.bank-card .bank-grid { margin-bottom: 8px; }
.bank-card .bank-queue { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
.bank-card .bank-queue li { padding: 3px 0; }
.bank-card .open { width: 100%; margin-top: 8px; }
.bank-card .bank-menu { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bank-card .bank-menu button { padding: 14px; font-size: 16px; }
.bank-card .back { margin-right: 6px; padding: 2px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; color: var(--text); font-size: 16px; }
/* 蜃人傳送：全螢幕星空地圖（tpmap.js） */
.tpmap { position: fixed; inset: 0; z-index: 60; background: #04060c; touch-action: none; }
.tpmap canvas { display: block; }
.tpmap .tp-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: max(12px, env(safe-area-inset-top)) 16px 12px; color: #cfe8ff; font-size: 17px; pointer-events: none; }
.tpmap .tp-top span { display: flex; gap: 8px; pointer-events: auto; }
.tpmap .tp-top button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid #2a4a6a; background: rgba(10,20,36,0.8); color: #cfe8ff; font-size: 20px; }
.tpmap .tp-bar { position: absolute; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid #2a4a6a; background: rgba(10,20,36,0.88); color: #cfe8ff; }
.tpmap .tp-bar.hidden { display: none; }
.tpmap .tp-name { font-weight: bold; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpmap .tp-dist { color: #ffe6aa; white-space: nowrap; }
.tpmap .go { padding: 10px 14px; border-radius: 10px; border: 1px solid #c8a050; background: #3a2c10; color: #ffe6aa; font-size: 15px; white-space: nowrap; }
.tpmap .go:disabled { opacity: 0.45; }

/* 長按的小選單、田的面板 */
.ctxmenu { position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 2px; padding: 6px; min-width: 150px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .45); pointer-events: auto; }
.ctxmenu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 16px; border-radius: 8px; border: 0; background: transparent; color: var(--text); white-space: nowrap; text-align: left; }
.ctxmenu button:hover, .ctxmenu button:active { background: rgba(140, 190, 255, .12); }
.ctxmenu .icon { width: 24px; height: 24px; flex: none; }
.menu-item .icon { width: 22px; height: 22px; vertical-align: -5px; }
.seeds { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0; }
.seed { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line); background: #13213a; color: var(--text); }
.seed .icon { width: 30px; height: 30px; }
.plot-card .pstate { text-align: center; margin: 10px 0; }
.workbar { position: fixed; z-index: 6; width: 64px; height: 8px; margin-left: -32px; border-radius: 4px; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .35); overflow: hidden; pointer-events: none; }
.workbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #9ad06a, #e0f0a0); }
/* 對話窗（地洞裡跟族人說話）：畫面下方，打字機效果，右下角 ▼ 跳動＝點一下下一句 */
.talkbox { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); width: min(520px, calc(100vw - 32px)); min-height: 84px;
  padding: 12px 16px 18px; border-radius: 12px; background: rgba(30, 20, 12, .92); border: 1px solid #8a6a44; color: #f2e2c8; pointer-events: auto; cursor: pointer; box-sizing: border-box; }
.talkbox b { display: block; font-size: 13px; color: #d8a860; margin-bottom: 4px; }
.talkbox p { margin: 0; font-size: 17px; line-height: 1.5; min-height: 1.5em; }
.talkbox .more { position: absolute; right: 14px; bottom: 6px; font-style: normal; font-size: 13px; color: #d8a860; opacity: 0; }
.talkbox.done .more { opacity: 1; animation: talkmore .6s ease-in-out infinite alternate; }
@keyframes talkmore { from { transform: translateY(0); } to { transform: translateY(4px); } }
/* 商人面板：一排一樣（圖示、名字、價格、按鈕），裝備的詞條在第二排 */
.mirage-card .trades li.trow { display: block; padding: 5px 2px; }
.mirage-card .tline { display: flex; align-items: center; gap: 6px; }
.mirage-card .tline .tname { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mirage-card .tline .price { margin: 0 4px 0 auto; }
.mirage-card .taff { margin: 2px 0 0 26px; font-size: 12px; line-height: 1.4; }
.mirage-card .tapinfo { cursor: pointer; }
.mirage-card .trow span { display: inline; flex: none; font-size: inherit; } /* 蓋掉 .trades li span 的直排 */
.mirage-card .trow .tapinfo { display: inline-flex; }
.mirage-card .taff .affix { margin-right: 8px; }
.stats.one { grid-template-columns: 1fr; }
.card .stats div { background: rgba(0, 0, 0, .3); }
.card.death p { color: #e0c8a0; }
.pow { font-style: normal; font-size: 12px; font-weight: 600; color: #ffcf6a; margin-left: 6px; white-space: nowrap; }
.itemtip .pow { display: block; margin: 2px 0 0; }

.machine-card .say { color: var(--dim); margin: 4px 0 8px; }

/* 眼睛的傷：那一側半邊畫面暗下來（lv1 殘、lv2 斷） */
.eyedark { position: absolute; top: 0; bottom: 0; width: 60%; pointer-events: none; opacity: 0; transition: opacity 1.5s; }
.eyedark.left { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, .6) 45%, transparent 100%); }
.eyedark.right { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, .6) 45%, transparent 100%); }
.eyedark.lv1 { opacity: .6; }
.eyedark.lv2 { opacity: 1; }

/* 選數量（長按背包、倉庫、箱子的一格；ui.js qtyPanel） */
.qty { position: fixed; z-index: 61; width: min(320px, calc(100vw - 32px)); padding: 10px 12px; border-radius: 12px; background: #0b1220f5; border: 1px solid #4a6a9a; color: var(--text); box-shadow: 0 4px 16px #0008; pointer-events: auto; }
.qty .qh b { display: block; }
.qty .qh small { display: block; color: var(--dim); margin-top: 2px; }
.qty .qrow { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
.qty .qrow button { min-width: 44px; height: 40px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: #1a2438; color: var(--text); font-size: 15px; }
.qty .qn { min-width: 52px; text-align: center; font-size: 22px; }
.qty .qrow .yes, .qty .qrow .no { flex: 1; }
.qty .qrow .yes { background: var(--accent); color: #04111c; font-weight: 700; border: 0; }
