/* 經典天堂倖存者：防跑版（文字、按鈕不超出框、不折行、不互相蓋住）——這份最後載入
   規則：名稱、標題、按鈕這類單行的字一律不折行；放不下由 js/fit.js 等比例縮小（最小 9px），還放不下才出現省略號
   檢查方法：瀏覽器主控台貼上 tools/跑版檢查.js 整份，電腦版、直式、橫式各跑一次（用法寫在那支檔案開頭） */

/* ---------- 單行元件：不折行、不超出框（字會自動縮小） ---------- */
.btn, .vb, .mini, .ttl, .sect, .nm, .pn, .i-nm, .en-nm, .pv-n, .pv-s, .cr-cn, .qt, .tn, .plv, .rc, .best,
.cxm .cn, .cxm .cc, .sel-info i, .st-rl, .st-rv, .vh-inf .nm, .vh-inf .sub3, .srow span, .vh-notice, .pflash, .card .lv, .vo-l, .vo-s {
  white-space: nowrap; overflow-x: clip; overflow-y: visible; text-overflow: ellipsis; min-width: 0;
}
.btn, .vb, .mini { max-width: 100%; box-sizing: border-box; }
.pflash { max-width: 92%; }
/* 分頁鈕：一排放不下就換到下一排，不會擠到字折成兩行或跑出視窗 */
.tabs { flex-wrap: wrap; }
.tabs > button { flex: none; }

/* ---------- 角色欄（選角）：資訊框的字上下不被切、名字不超出職業卡 ---------- */
.sel-info i { line-height: 1.35; }
.sel-slot .sn, .sel-slot .sl { white-space: nowrap; overflow-x: clip; text-overflow: ellipsis; max-width: 62%; }

/* ---------- 視窗：最寬就是畫面可用的寬度（扣掉邊距），不會超出畫面被切 ---------- */
.scr > .frame { max-width: 100%; }

/* ---------- 章節卡：文字區可以縮窄，名稱放不下就縮小字 ---------- */
.chap .bd { min-width: 0; flex: 1; }

/* ---------- 每日任務：任務名稱一行放得下 ---------- */
.quest .qt { width: 300px; }

/* ---------- 村莊：電腦版視窗不夠寬時，聊天框移到按鈕列上面，不跟「出發」疊在一起 ---------- */
@media (min-width: 761px) and (max-width: 1240px) and (pointer: fine) {
  .chat { bottom: 70px; }
}

/* ---------- 直式手機 ---------- */
@media (max-width: 640px), (max-aspect-ratio: 4 / 5) {
  /* 寬度用 100%（扣掉捲軸），不用 100vw，右邊才不會被切掉一截 */
  .sel-stage, .cr-stage { width: 100% !important; }
  /* 建角兩個步驟：最下面一條不透明的按鈕列；內容捲到下面會藏到按鈕列後面，不會跟「退回／確認」疊在一起 */
  .cr-stage { padding-bottom: 108px !important; }
  .cr-scr { scroll-padding-bottom: 110px; }   /* 跳到輸入框（例如沒取名字就按確認）時捲到按鈕列上面，不會被擋住 */
  .cr-stage::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 92px; z-index: 3; pointer-events: none;
    background: linear-gradient(rgba(5, 4, 3, 0), rgba(5, 4, 3, .9) 28%, #050403 58%); }
  .cr-stage .obtn.cr-back, .cr-stage .obtn.next, .st-stage .obtn.st-back, .st-stage .obtn.st-ok { z-index: 4; }
  .cr-stage .msg.cr-msg, .st-stage .msg.st-msg { position: fixed !important; left: 8px; right: 8px; top: auto; bottom: 58px; z-index: 4; margin: 0; pointer-events: none; }
  /* 章節卡片：跟著視窗寬度，不超出框 */
  .chap { width: 100%; }
}

/* ---------- 橫式手機：能力值畫面改成左右兩欄（原本 4:3 縮太小，詳細能力的字會被切掉） ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .st-stage { width: 100% !important; aspect-ratio: auto; min-height: 100vh; box-sizing: border-box; padding: 8px 12px 104px;
    background-size: cover; background-position: 60% top;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "t t" "l r" "b r" "p p" "n n"; align-items: start; gap: 8px 14px; }
  .st-title, .st-left, .st-right, .st-btns2, .st-name, .st-msg, .st-tip { position: relative; left: auto; top: auto; bottom: auto; }
  .st-tip { grid-area: p; width: auto; }
  .st-title { grid-area: t; width: 150px; }
  .st-left { grid-area: l; width: 100%; }
  .st-right { grid-area: r; width: 100%; }
  .st-btns2 { grid-area: b; width: 100%; }
  .st-name { grid-area: n; justify-self: center; width: min(300px, 70vw); }
  .st-stage::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 86px; z-index: 3; pointer-events: none;
    background: linear-gradient(rgba(5, 4, 3, 0), rgba(5, 4, 3, .9) 28%, #050403 58%); }
  .cr-scr { scroll-padding-bottom: 100px; }
  .st-stage .obtn.st-back, .st-stage .obtn.st-ok { position: fixed; bottom: 10px; z-index: 4; }
  .st-stage .obtn.st-back { left: 10px; right: auto; width: 100px; }
  .st-stage .obtn.st-ok { right: 10px; left: auto; width: 150px; }
  .st-stage .msg.st-msg { position: fixed !important; left: 8px; right: 8px; bottom: 54px; z-index: 4; margin: 0; pointer-events: none; }
}

/* ---------- 讀取畫面：進度條放進背景圖（原版 loading，640×480）裡的花紋凹槽，任何螢幕尺寸都對齊 ----------
   背景圖顯示寬度＝--lw（跟 stat.css 的 .load-bg::after 一樣），置中；凹槽在圖上 x 246～394、y 397～401
   → 中心在畫面正中往下 0.2484×--lw，寬 0.2313×--lw；字放在花紋框正下方 */
#scrLoad { --lw: min(100vw, 1067px, calc(100vh * 4 / 3)); }
#scrLoad .load-box { position: absolute; inset: 0; width: auto; transform: none; pointer-events: none; }
#scrLoad .lbar { position: absolute; left: 50%; top: calc(50% + var(--lw) * 0.2484); width: calc(var(--lw) * 0.2313); height: max(3px, calc(var(--lw) * 0.0072));
  transform: translate(-50%, -50%); border: 0; background: rgba(0, 0, 0, .65); }
#scrLoad .lbar i { background: linear-gradient(#fff7cf, #e8b84a 55%, #8a5a10); box-shadow: 0 0 6px rgba(255, 210, 120, .75); }
#scrLoad #loadTxt { position: absolute; left: 50%; top: calc(50% + var(--lw) * 0.2484 + var(--lw) * 0.022 + 8px); transform: translateX(-50%); margin: 0; white-space: nowrap; }

/* ---------- 血盟的表格（排行、成員、申請）：手機上不超出框、不用左右捲 ---------- */
@media (max-width: 760px) {
  table.tb th, table.tb td { padding: 4px 3px; }
  table.tb td.acts { white-space: normal; width: 1%; }
  table.tb td.acts .mini { display: block; width: 100%; margin: 2px 0; }
  .clan-body table.tb td.cl { white-space: normal; }
}
@media (max-width: 440px) {
  .clan-body table.tb.clans th:nth-child(5), .clan-body table.tb.clans td:nth-child(5),
  .clan-body table.tb.members th:nth-child(5), .clan-body table.tb.members td:nth-child(5),
  .clan-body table.tb.applies td:nth-child(4) { display: none; }
}

/* ---------- 聊天：訊息從下面往上長（最新一行貼著輸入框），訊息多了照樣可以往上捲 ---------- */
.chat-log { display: flex; flex-direction: column; }
.chat-log > :first-child { margin-top: auto; }

/* ---------- 手機用「實際看得到的高度」排版（svh：扣掉網址列和下方工具列）----------
   iPhone 的 100vh 是工具列收起來時的高度，比實際看得到的高，畫面會要往下滑；能用 svh 的瀏覽器一律改用 svh */
@supports (height: 100svh) {
  @media (max-width: 640px), (max-aspect-ratio: 4 / 5) {
    .cr-stage, .sel-stage { min-height: 100svh; }
    .cr-stage { background-size: auto 100svh; background-position: max(calc(100vw - 133.33svh), min(0px, calc(50vw - var(--fx, .62) * 133.33svh))) 0; }
    /* 角色欄：拱門場景高度照實際高度算，資訊框、角色卡、底部按鈕一定放得下 */
    .sel-stage { --sh: min(75svh, calc((100svh - 400px) / .573)); }
    /* 能力值：面板寬度也照實際高度縮，整頁不用捲 */
    .st-left, .st-btns2, .st-tip { width: min(383px, 96vw, calc((100svh - 286px) * 383 / 350)); }
  }
}
/* ---------- 直式選職業：職業徽章、男女鈕底下墊一條暗色帶，亮的職業大圖上也看得清楚 ---------- */
@media (max-width: 640px), (max-aspect-ratio: 4 / 5) {
  .cr-classes { background: linear-gradient(rgba(5, 4, 3, 0), rgba(5, 4, 3, .82) 18%, rgba(5, 4, 3, .86)); padding: 10px 6px 8px; gap: 6px 4px; margin: 0 -10px; width: calc(100% + 20px) !important; }
  .cr-cls { width: 18vw; max-width: 72px; filter: brightness(1.3) drop-shadow(0 0 3px #000); }
  .cr-g { width: 15vw; max-width: 58px; }
  .cr-info { margin-bottom: -10px; }
}

/* 血盟、排行榜、精靈屬性：村莊上的視窗（11-16 改，不再換成有背景圖的全畫面）；視窗本身會捲，裡面不要再一層捲動 */
.frame.pnl.clan { width: 820px; max-width: 100%; }
.frame.pnl.rank { width: 860px; max-width: 100%; }
.frame.pnl.elem { width: 790px; max-width: 100%; }
.pnl .clan-body, .pnl .rank-body { max-height: none; overflow: visible; flex: none; min-height: 0; }
/* 血盟、排行榜：電腦版固定高度（11-16 使用者：視窗不要跟著內容變高變矮），內容多就在框裡捲 */
@media (min-width: 761px) and (min-height: 521px) { .frame.pnl.clan, .frame.pnl.rank { height: min(640px, 94vh); } }
/* 怪物圖鑑改成點村莊 NPC 倫德羅才開（11-16），手機下方的圖鑑鈕拿掉 */

.pnl .elem-list { margin-top: 8px; }
/* 手機下方按鈕（11-16）：多了「天賦」，商城打開時「出發」改佔一格，兩排各 4 顆排滿（不會有一顆掉到第三排），聊天框維持兩排的高度 */
@media (max-width: 760px), (pointer: coarse) {
  .vh-btns:has(#vbMall:not(.hide)) .vb.go { grid-column: span 1; }
  #vhud.mall .chat { bottom: 98px; }
}

/* ===== 升級畫面：重抽／放逐／跳過（11-17） ===== */
.lvact { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.lvact .btn { min-width: 96px; }
.lvact .btn b { color: #ffe28a; margin-left: 4px; }
.lvact .btn.on { color: #ff9a8a; box-shadow: 0 0 10px rgba(230, 70, 40, .7); }
.lvhint { min-height: 18px; margin-top: 6px; font-size: 13px; color: #ffb4a0; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.cards.banning .card:not(.noban) { position: relative; outline: 3px solid rgba(235, 70, 40, .95) !important; outline-offset: -2px; }
.cards.banning .card:not(.noban)::after { content: '點這張放逐'; position: absolute; left: 50%; top: -14px; transform: translateX(-50%); padding: 1px 8px; font-size: 12px; font-weight: 900; color: #fff; background: #b8301c; border: 1px solid #ff8a6a; white-space: nowrap; pointer-events: none; }
.cards.banning .card.noban { opacity: .35; cursor: default; }
@media (max-width: 760px) {
  .lvact { gap: 6px; margin-top: 8px; }
  .lvact .btn { min-width: 0; flex: 1 1 0; }
  .lvhint { font-size: 11px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .lvact { margin-top: 6px; }
  .lvhint { min-height: 0; font-size: 11px; margin-top: 2px; }
}

/* ===== 怪物魔石（11-17） ===== */
.ic .skm, .iw-c .skm { position: absolute; left: 1px; bottom: 1px; width: 13px !important; height: 13px !important; image-rendering: pixelated; filter: drop-shadow(0 0 2px #000); pointer-events: none; }
.skn { color: #c9a8ff; font-weight: 700; }
.skw { margin: 6px 0 4px; border-top: 1px solid rgba(160, 130, 70, .35); padding-top: 4px; }
.skr { display: flex; align-items: center; gap: 6px; min-height: 30px; font-size: 13px; }
.skr img { width: 24px; height: 24px; flex: none; image-rendering: pixelated; }
.skh { flex: none; color: #bfae84; font-size: 12px; }
.skt { flex: 1; min-width: 0; color: #e2d6b4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skt small { display: block; font-size: 11px; color: #9fd0a0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skr .mini { flex: none; }
.skl { max-height: min(46vh, 360px); overflow-y: auto; text-align: left; margin: 6px 0; border: 1px solid #3a3226; background: rgba(0, 0, 0, .45); }
.skp { display: flex; align-items: center; gap: 8px; padding: 5px 8px; cursor: pointer; border-bottom: 1px solid rgba(90, 76, 50, .4); font-size: 14px; color: #e2d6b4; }
.skp:hover { background: rgba(160, 120, 50, .18); }
.skp input { flex: none; width: 16px; height: 16px; accent-color: #c9a24e; }
.skp img { width: 28px; height: 28px; flex: none; image-rendering: pixelated; }
.skp span { min-width: 0; }
.skp small { display: block; font-size: 12px; color: #9fd0a0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skn2 { font-size: 12px; }
.lit.stone .ic { box-shadow: 0 0 8px 2px rgba(190, 140, 255, .85) !important; }
.lit.stone .inm { color: #d8b8ff !important; }
.cxm { position: relative; }
.cxm .cxst { position: absolute; right: 3px; top: 3px; width: 18px; height: 18px; image-rendering: pixelated; filter: drop-shadow(0 0 2px #000); }
.cxm:has(.cxst) { cursor: pointer; }

/* ===== 神祇的祝福：金色卡（11-17） ===== */
.card.gold { filter: drop-shadow(0 0 10px rgba(255, 205, 80, .95)) brightness(1.08); animation: goldPulse 1.6s ease-in-out infinite; }
.card.gold .nm { color: #ffe08a !important; text-shadow: 0 0 6px rgba(255, 190, 60, .8); }
.card .lv.gold { color: #ffd060; }
@keyframes goldPulse { 0%, 100% { filter: drop-shadow(0 0 7px rgba(255, 205, 80, .8)) brightness(1.05); } 50% { filter: drop-shadow(0 0 14px rgba(255, 220, 120, 1)) brightness(1.15); } }
@media (prefers-reduced-motion: reduce) { .card.gold { animation: none; } }
.cards.banning .card.gold { opacity: .35; }
.card .ds .gd2 { color: #ffd060; font-size: .92em; }

/* ===== 物品託售（11-17，js/consignui.js；視窗跟商店同一套固定高度） ===== */
.cs-flt { gap: 4px; }
.cs-flt .cs-q { display: inline-flex; gap: 4px; align-items: center; margin-left: 4px; }
.cs-flt .cs-q .inp { width: 130px; height: 26px; box-sizing: border-box; padding: 0 6px; font-size: 13px; }
.cs-flt select { height: 26px; background: #120d07; color: #e2d6b4; border: 1px solid #5a4a2a; font: inherit; font-size: 13px; }
.cs-lw { width: 380px; flex: none; display: flex; flex-direction: column; min-height: 0; }
.cs-lw .slist { width: auto; flex: 1 1 auto; min-height: 120px; }
.cs-pg { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 2px 0; font-size: 12px; color: #bfae84; white-space: nowrap; }
.cs-row { gap: 8px; }
.cs-row .cs-ic { position: relative; width: 32px; height: 32px; flex: none; }
.cs-row .cs-ic img { width: 32px; height: 32px; }
.cs-row .cs-ic .skm { position: absolute; left: 0; bottom: 0; width: 12px !important; height: 12px !important; }
.cs-row .cs-n { flex: 1; min-width: 0; display: block; white-space: nowrap; overflow: hidden; }
.cs-row .cs-n i { font-style: normal; }
.cs-row .cs-n em { font-style: normal; color: #9fd0ff; margin-left: 4px; font-size: 13px; }
.cs-row .cs-n small { display: block; font-size: 11px; color: #a89a78; overflow: hidden; text-overflow: ellipsis; }
.cs-row b { flex: none; color: #ffe28a; }
.cs-row.mine { background: rgba(90, 140, 200, .10); }
.cs-row .mini { flex: none; }
.cs-who { font-size: 13px; color: #d4c7a2; margin: 6px 0 4px; line-height: 1.6; }
.cs-who b.gold, .tot b.gold, b.gold { color: #ffd34a; }
.cs-lab { font-size: 12px; color: #bfae84; margin: 6px 0 2px; }
.cs-price { width: 140px; }
.cs-rule { font-size: 12px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; }
.cs-mine { display: flex; flex-direction: column; gap: 4px; }
.cs-mine .slist { width: auto; max-height: none; }
.cs-sales { border: 1px solid #4e3e1e; background: rgba(0, 0, 0, .35); }
.cs-sale { display: flex; gap: 10px; padding: 4px 8px; font-size: 13px; border-bottom: 1px solid rgba(78, 62, 30, .5); white-space: nowrap; }
.cs-sale span:nth-child(1) { color: #a89a78; flex: none; }
.cs-sale span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cs-sale span:nth-child(3) { color: #a89a78; flex: none; max-width: 30%; overflow: hidden; text-overflow: ellipsis; }
.cs-sale b { color: #8fe08a; flex: none; }
@media (min-width: 761px) {
  .pnl.shop.cs .pnl-body > .cs-mine { flex: 1 1 0; min-height: 0; overflow-y: auto; }
}
@media (max-width: 760px) {
  .cs-lw { width: auto; }
  .cs-flt .cs-q .inp { width: 110px; }
  .cs-rule { white-space: normal; }
}

/* 綁定的道具（11-17：每日任務的獎勵）：格子右上角「綁」、說明一行、每日任務的「綁定」小標 */
.ic .bd, .iw-c .bd { position: absolute; right: 1px; top: 0; font-style: normal; font-size: 10px; font-weight: 700; line-height: 12px; color: #ffb070; text-shadow: 0 0 2px #000, 0 0 2px #000; pointer-events: none; }
.bdl { color: #ffb070; }
.bdt { display: inline-block; margin-left: 6px; padding: 0 4px; font-size: 11px; line-height: 15px; color: #ffb070; border: 1px solid rgba(255, 150, 80, .55); border-radius: 2px; vertical-align: middle; white-space: nowrap; }

/* 寶箱開箱演出（11-17，js/chestfx.js）：畫布在卡片後面；卡片從寶箱裡飛出來；金色卡落定時亮一下 */
.chest-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.chest-fx.over { z-index: 2; }   /* 金色卡的天降金光、星芒畫在卡片前面 */
#scrLevel .lvbox { position: relative; z-index: 1; }
#scrLevel.opening .card:not(.fly):not(.out) { opacity: 0; }
#scrLevel.opening .lvact, #scrLevel.opening #lvHint { visibility: hidden; }
.card.fly { animation: cardFly calc(.4s / var(--chsp, 1)) cubic-bezier(.18, .9, .3, 1.12) both; pointer-events: none; }
@keyframes cardFly { 0% { opacity: 0; transform: translate(var(--fx, 0), var(--fy, 0)) scale(.12) rotate(var(--fr, 0deg)); } 30% { opacity: 1; } 100% { opacity: 1; transform: none; } }
.card.gold.gold-in { animation: goldIn calc(.75s / var(--chsp, 1)) ease-out; }
@keyframes goldIn { 0% { filter: drop-shadow(0 0 28px rgba(255, 225, 130, 1)) brightness(2.1); transform: scale(1.09); } 100% { filter: drop-shadow(0 0 10px rgba(255, 205, 80, .95)) brightness(1.08); transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .card.fly { animation-duration: .01s; } }

/* 選角卡片：等級、名字排在上面中間一排（11-17 使用者畫的位置：職業盾牌右邊、人物圖左邊，不壓到人物） */
.sel-slot .sinfo { position: absolute; left: 27.7%; right: 32%; top: 19.5%; display: flex; align-items: baseline; line-height: 1.2; pointer-events: none; }
.sel-slot .sinfo .sl, .sel-slot .sinfo .sn { position: static; max-width: none; }
.sel-slot .sinfo .sl { flex: 0 0 33%; text-align: center; }
.sel-slot .sinfo .sn { flex: 1 1 auto; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 排行榜分類（11-17 使用者：手機太亂）：上面 5 個大分類、下面小分類，一排等寬不折行；「本週」寫在下面一行小字 */
#rankTabs.tabs { display: block; margin-bottom: 6px; }
#rankTabs .rk-cat, #rankTabs .rk-sub { display: grid; gap: 6px; }
#rankTabs .rk-sub { margin-top: 6px; }
#rankTabs .btn { min-width: 0; padding-left: 2px; padding-right: 2px; border-left-width: 6px; border-right-width: 6px; white-space: nowrap; overflow: hidden; text-overflow: clip; }   /* 原版按鈕外框左右各 16 像素太寬，窄按鈕放不下字 */
#rankTabs .rk-cat .btn { font-size: 14px; letter-spacing: 0; }
#rankTabs .rk-sub .btn { font-size: 13px; letter-spacing: 0; }
#rankTabs .rk-cap { margin-top: 6px; text-align: center; font-size: 12px; color: #a89a78; white-space: nowrap; }
@media (max-width: 760px) { #rankTabs .rk-sub[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }   /* 手機：第 1～6 章一排 3 顆、兩排 */

/* 血盟：招募開關、入盟步驟（11-17） */
.clan-rc { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 2px; padding: 6px 10px; background: rgba(0, 0, 0, .35); border: 1px solid #3a3226; white-space: nowrap; }
.clan-rc > span { min-width: 0; overflow: hidden; }
.note.clan-how { margin-top: 6px; color: #e8d29a; }
