/* ===== 冒險者物語 v1 ===== */
:root { --gold: #f3d48a; --ink: #e9dcc0; --panel: rgba(24,17,12,.96); --line: #6d5330; --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0907; overflow: hidden; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; font-family: "Noto Serif TC", "Microsoft JhengHei", "PingFang TC", serif; color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* iPhone：不要雙擊／雙指放大；遊戲畫面完全自己處理觸控；輸入框字級 >= 16px（Safari 才不會自動放大） */
#app, #cv, #hud, #joy { touch-action: none; overscroll-behavior: none; }
input, select, textarea { font-size: 16px; touch-action: manipulation; -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
#app { position: fixed; inset: 0; overflow: hidden; background: #000; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---- 狀態列 ---- */
#status { position: absolute; left: calc(8px + var(--sal)); top: calc(8px + var(--sat)); width: 230px; height: 84px; pointer-events: none; }
#portrait { position: absolute; left: 0; top: 0; width: 72px; height: 72px; border-radius: 50%; background: #1a120c center/80% no-repeat; }
#portrait::after { content: ""; position: absolute; inset: -4px; background: url(../assets/ui/portrait-frame.webp) center/100% no-repeat; }
#name { position: absolute; left: 80px; top: 2px; color: var(--gold); font-size: 15px; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; }
.bar { position: absolute; left: 78px; width: 148px; background: rgba(0,0,0,.65); border: 1px solid #3b2a16; border-radius: 3px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; display: block; }
#hpbar { top: 24px; height: 17px; }
#hpfill { background: linear-gradient(#e2433f, #8f1714); transition: width .12s; }
#shfill { background: rgba(255,233,160,.55); }
#hptext { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 0 3px #000; }
#expbar { top: 45px; height: 7px; }
#expfill { background: linear-gradient(#f5d36b, #a07a1c); }
#gold { position: absolute; left: 80px; top: 56px; font-size: 13px; color: #ffe1a0; text-shadow: 0 0 3px #000; display: flex; align-items: center; gap: 4px; }
.coin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, #e0a520 60%, #8a5a08); box-shadow: 0 0 2px #000; }

/* ---- 右上選單 ---- */
#menu { position: absolute; right: calc(6px + var(--sar)); top: calc(6px + var(--sat)); display: flex; gap: 4px; }
.mbtn { position: relative; width: 52px; height: 58px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(#2c1f14, #150e09); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.6); }
.mbtn i { width: 32px; height: 32px; background: center/contain no-repeat; font-style: normal; font-size: 24px; line-height: 32px; text-align: center; color: #d9c08a; }
.mbtn span { font-size: 11px; color: var(--gold); }
.badge { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #c4302b; color: #fff; font-size: 11px; line-height: 18px; text-align: center; display: none; }
.badge.on { display: block; }

/* ---- 王 ---- */
#bossArea { position: absolute; left: 50%; transform: translateX(-50%); top: calc(92px + var(--sat)); width: min(78%, 420px); text-align: center; pointer-events: none; }
#gauge { width: 150px; margin: 0 auto; font-size: 11px; color: #cdb98d; text-shadow: 0 0 3px #000; }
.gbar { height: 6px; background: rgba(0,0,0,.6); border: 1px solid #4a3620; border-radius: 3px; overflow: hidden; margin-top: 2px; }
.gbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5a8cff, #c7e0ff); }
#bossBtn { pointer-events: auto; margin-top: 6px; padding: 7px 18px; border: 1px solid #c79a4a; border-radius: 8px; background: linear-gradient(#6b1d14, #2a0a08); color: #ffdca0; font-size: 15px; text-shadow: 0 1px 2px #000; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 14px #ff6a3a; } }
#bossname { color: #ffd9a0; font-size: 14px; text-shadow: 0 0 4px #000, 0 0 2px #000; margin-bottom: 3px; }
#bossbg { position: relative; height: 13px; background: rgba(0,0,0,.7); border: 1px solid #8a6a35; border-radius: 3px; overflow: hidden; }
#bosshp { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#c93b2f, #6d120c); transition: width .15s; }

/* ---- 掉寶訊息 ---- */
#lootFeed { position: absolute; right: calc(8px + var(--sar)); top: calc(74px + var(--sat)); width: 170px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; pointer-events: none; }
#lootFeed div { font-size: 12px; padding: 2px 6px; background: rgba(0,0,0,.55); border-radius: 4px; text-shadow: 0 0 2px #000; animation: fadeout 3.2s forwards; white-space: nowrap; }
@keyframes fadeout { 0% { opacity: 0; transform: translateX(10px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---- 搖桿與按鈕 ---- */
#joy { position: absolute; left: 0; bottom: 0; width: 50%; height: 60%; }
#jbase { position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px; background: url(../assets/ui/joystick-base.webp) center/100% no-repeat; opacity: .4; pointer-events: none; }
#jknob { position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px; background: url(../assets/ui/joystick-knob.webp) center/100% no-repeat; pointer-events: none; opacity: .8; }
#joy.on #jbase { opacity: .85; }
#auto { position: absolute; left: calc(10px + var(--sal)); bottom: calc(14px + var(--sab)); width: 132px; height: 38px; border: 0; background: url(../assets/ui/button-auto-battle.webp) center/100% 100% no-repeat; color: #ffe9c0; font-size: 14px; text-shadow: 0 1px 2px #000; }
#auto.off { filter: grayscale(1) brightness(.75); }
.btn { position: absolute; border-radius: 50%; touch-action: none; }
.btn .ic { position: absolute; inset: 14%; border-radius: 50%; background: center/cover; }
.btn .fr { position: absolute; inset: 0; background: center/100% 100% no-repeat; pointer-events: none; }
.btn .cd { position: absolute; inset: 14%; border-radius: 50%; background: conic-gradient(rgba(0,0,0,.72) calc(var(--p, 0) * 1turn), transparent 0); pointer-events: none; }
.btn .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: bold; text-shadow: 0 0 4px #000; pointer-events: none; }
.btn.press .ic { filter: brightness(1.45); }
.btn.locked .ic { filter: grayscale(1) brightness(.4); }
.btn .lockt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #e8d4a6; font-size: 12px; text-shadow: 0 0 3px #000; pointer-events: none; }
.tag { position: absolute; left: 50%; top: -16px; width: 44px; height: 19px; transform: translateX(-50%); background: center/100% 100% no-repeat; color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; text-shadow: 0 0 3px #000; }

#toast { position: absolute; left: 0; right: 0; top: 34%; text-align: center; color: #ffd77a; font-size: 22px; padding: 0 20px; text-shadow: 0 0 8px #000, 0 0 3px #a33; opacity: 0; transition: opacity .3s; pointer-events: none; }
#toast.big { font-size: 28px; }
#errbox { position: absolute; left: 8px; right: 8px; bottom: 40%; padding: 10px; background: rgba(80,10,10,.9); border: 1px solid #c55; border-radius: 6px; font-size: 13px; color: #fff; z-index: 30; }

/* ---- 視窗 ---- */
#panel { position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(100%, 560px); max-height: 88%; display: flex; flex-direction: column; background: var(--panel); border: 2px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.7); padding-bottom: var(--sab); }
@media (orientation: landscape) and (max-height: 600px) { #panel { align-items: center; } .sheet { max-height: 96%; border-radius: 12px; border-bottom: 2px solid var(--line); width: min(96%, 760px); } }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #3c2b18; color: var(--gold); font-size: 17px; background: linear-gradient(#2e2015, transparent); border-radius: 12px 12px 0 0; }
#pclose { border: 1px solid var(--line); background: #1d140c; border-radius: 6px; width: 34px; height: 30px; }
#pbody { overflow-y: auto; padding: 10px 12px 16px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.sp { flex: 1; }
.btn2 { border: 1px solid var(--line); background: linear-gradient(#3a2817, #1c130b); border-radius: 7px; padding: 7px 11px; font-size: 13px; color: var(--gold); min-height: 34px; }
.btn2:disabled { opacity: .4; }
.btn2.red { border-color: #8a3a2a; color: #ffb9a0; }
.btn2.blue { border-color: #3a5a8a; color: #bcd6ff; }
.btn2.on { background: linear-gradient(#5a4020, #2e2010); color: #fff1c8; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs .btn2 { flex: 1; }
.muted { color: #9d8c6c; font-size: 12px; }
.sec { margin: 12px 0 6px; color: var(--gold); font-size: 14px; border-bottom: 1px solid #3a2a17; padding-bottom: 3px; }

/* 裝備格 */
.eqrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; }
.cell { position: relative; aspect-ratio: 1; border: 2px solid #4a3a28; border-radius: 7px; background: radial-gradient(#2a1f16, #120c08); padding: 3px; }
.cell img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.cell.empty { opacity: .45; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #8a7a5a; }
.cell.sel { outline: 2px solid #fff3c0; outline-offset: 1px; }
.cell .plus { position: absolute; left: 3px; top: 1px; font-size: 11px; color: #9dff9d; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.cell .lk { position: absolute; right: 2px; top: 0; font-size: 11px; }
.cell .up { position: absolute; right: 3px; bottom: 1px; font-size: 13px; color: #6dff6d; font-weight: bold; text-shadow: 0 0 2px #000; }
.cell .slotname { position: absolute; left: 0; right: 0; bottom: -1px; text-align: center; font-size: 9px; color: #bba57a; text-shadow: 0 0 2px #000; }
.r-white { border-color: #8f8a80; } .r-blue { border-color: #3d86e0; box-shadow: inset 0 0 8px rgba(60,130,230,.4); }
.r-purple { border-color: #a95ce6; box-shadow: inset 0 0 10px rgba(170,90,230,.45); } .r-gold { border-color: #f0b83a; box-shadow: inset 0 0 12px rgba(240,184,58,.55), 0 0 6px rgba(240,184,58,.4); }

/* 物品詳細 */
.card { margin-top: 10px; border: 1px solid #4a3620; border-radius: 9px; padding: 10px; background: rgba(0,0,0,.3); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .ln { font-size: 13px; line-height: 1.6; }
.card .aff { color: #9fd0ff; } .card .spc { color: #ffc845; } .card .upg { color: #9dff9d; }
.cmp { font-size: 12px; margin-top: 6px; line-height: 1.6; }
.cmp .g { color: #6dff6d; } .cmp .b { color: #ff7a6a; }
.pips { display: flex; gap: 3px; margin: 6px 0; }
.pips i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #5a4a30; background: #1a120b; }
.pips i.ok { background: #4fc24f; } .pips i.ng { background: #c0392b; }
.scrollbtn { display: flex; align-items: center; gap: 6px; text-align: left; }
.scrollbtn img { width: 32px; height: 32px; }
.enres { text-align: center; font-size: 24px; height: 34px; margin-top: 4px; }
.enres.ok { color: #7dff7d; text-shadow: 0 0 10px #2a2; animation: pop .5s; } .enres.ng { color: #ff7a6a; animation: shake .4s; }
@keyframes pop { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* 卷軸表：左邊名稱＋說明，右邊 4 種成功率的數量（390px 直版不爆版） */
.slist { display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, minmax(38px, 46px)); gap: 5px 4px; align-items: center; font-size: 12px; }
.slist .hd { font-size: 11px; color: #9d8c6c; } .slist .hd.c { text-align: center; color: var(--gold); font-size: 12px; }
.slab { display: flex; align-items: center; gap: 5px; min-width: 0; }
.slab .sb { width: 38px; height: 38px; flex: none; }
.slab .st { min-width: 0; }
.slab .sn { font-size: 13px; color: #f0dca8; display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.si { width: 16px; height: 16px; object-fit: contain; vertical-align: middle; margin-right: 2px; }
.slab .sg { font-size: 10.5px; color: #9fd09f; line-height: 1.3; }
.scell { height: 40px; border: 1px solid #5a4428; border-radius: 6px; background: radial-gradient(#2c2016, #120c08); color: #fff1c8; font-size: 15px; font-weight: bold; padding: 0; }
.scell:active { outline: 2px solid #fff3c0; }
.scell.zero { opacity: .35; font-weight: normal; color: #8a7a5a; }
.scrollbtn.pre { outline: 2px solid #ffd86b; box-shadow: 0 0 10px rgba(255,216,107,.5); }
.spop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.spbox { width: min(100%, 360px); background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 6px 30px rgba(0,0,0,.8); }
.spbox h3 { margin: 0; font-size: 18px; color: #f3d48a; } .spbox .rate { color: #fff; }
.spimg { width: 64px; height: 64px; }
.spbox dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 10px 0 12px; font-size: 13px; }
.spbox dt { color: #9d8c6c; } .spbox dd { margin: 0; line-height: 1.45; } .spbox dd small { color: #9d8c6c; font-size: 11px; }
.spbox .g { color: #7dff7d; } .spbox .b { color: #ff8a7a; }
#lootFeed div img { width: 18px; height: 18px; vertical-align: middle; margin-right: 3px; }

/* 能力／技能 */
.statrow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #2c2012; }
.statrow .nm { width: 46px; color: var(--gold); font-size: 15px; }
.statrow .val { width: 64px; font-size: 15px; }
.statrow .ds { flex: 1; font-size: 11px; color: #a8987a; }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: 13px; }
.dgrid span:nth-child(odd) { color: #b9a57c; }
.skrow { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #2c2012; }
.skrow .sic { width: 52px; height: 52px; border-radius: 50%; background: center/cover; flex-shrink: 0; border: 2px solid #6a5030; }
.skrow.lock .sic { filter: grayscale(1) brightness(.5); }
.skrow .info { flex: 1; font-size: 12px; line-height: 1.5; }
.skrow .info b { color: var(--gold); font-size: 14px; }
.skrow .ms { color: #8a7a5a; } .skrow .ms.got { color: #9dff9d; }

/* 選職業 */
#select { position: absolute; inset: 0; z-index: 25; overflow-y: auto; padding: calc(20px + var(--sat)) 14px 20px; background: radial-gradient(ellipse at 50% 30%, #2a1c12, #0b0907 70%); text-align: center; touch-action: pan-y; }
#select h1 { margin: 10px 0 2px; color: var(--gold); font-size: 30px; letter-spacing: 4px; text-shadow: 0 0 12px rgba(255,180,80,.4); }
#select .sub { margin: 0 0 18px; color: #a8916a; font-size: 14px; }
#cards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.ccard { width: min(100%, 220px); border: 2px solid var(--line); border-radius: 12px; background: linear-gradient(#2a1d13, #140d08); padding: 12px; text-align: center; }
.ccard:active { transform: scale(.98); }
.ccard .pt { width: 96px; height: 96px; margin: 0 auto 6px; border-radius: 50%; background: #1a120c center/85% no-repeat; border: 2px solid #8a6a3a; }
.ccard h2 { margin: 4px 0; font-size: 20px; color: var(--gold); }
.ccard p { margin: 4px 0; font-size: 12px; color: #c4b08a; line-height: 1.5; }
.ccard .sv { color: #9dff9d; font-size: 13px; }
#select .hint { color: #7d6c50; font-size: 12px; margin-top: 18px; }
#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #e8d4a6; background: #0b0907; font-size: 18px; z-index: 40; }
#loading small { margin-top: 10px; color: #8d7a58; font-size: 13px; }

/* 直向窄螢幕：選單改成右側直排，避免蓋到狀態列 */
@media (max-width: 600px) and (orientation: portrait) {
  #menu { flex-direction: column; gap: 5px; }
  .mbtn { width: 50px; height: 54px; }
  #lootFeed { right: calc(64px + var(--sar)); top: calc(70px + var(--sat)); }
  #bossArea { top: calc(96px + var(--sat)); width: min(70%, 420px); transform: translateX(-56%); }
}
.nw { white-space: nowrap; }
/* 戰鬥數值（能力視窗） */
.lsbox { display: block; width: 100%; text-align: left; border: 1px solid #7a2a2a; border-radius: 9px; background: linear-gradient(#3a1414, #1a0a0a); padding: 8px 10px; color: #f3e2c0; }
.lsbox.on, .cs.on { outline: 2px solid #ffd86b; }
.lsbox .nm { color: #ff8a8a; font-size: 15px; } .lsbox .lsv { font-size: 20px; color: #ff6a6a; }
.lsl { font-size: 12px; line-height: 1.5; margin-top: 2px; } .lsl b { color: #ff9a9a; }
.csgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 6px; }
.cs { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; min-width: 0; border: 1px solid #4a3620; border-radius: 7px; background: rgba(0,0,0,.3); padding: 7px 8px; color: #f3e2c0; font-size: 13px; }
.cs .nm { color: #b9a57c; white-space: nowrap; } .cs .v { text-align: right; white-space: nowrap; }
.cs .v small { display: block; font-size: 10px; color: #9d8c6c; }
.csx { margin-top: 6px; font-size: 12px; line-height: 1.5; color: #d8c8a0; background: rgba(0,0,0,.35); border-radius: 7px; padding: 7px 9px; min-height: 36px; }
.csx b { color: var(--gold); }

/* ===== 手機防爆版（iPhone Safari 360～414px）=====
   Safari 會把格子裡圖片的原始寬度（112px）當成最小寬度，1fr 就被撐爆 → 一律用 minmax(0,1fr) + min-width:0 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.sheet { max-width: 100%; }
#pbody { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
.eqrow { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(3px, 1.4vw, 6px); }
.grid { grid-template-columns: repeat(auto-fill, minmax(min(52px, 100%), 1fr)); }
.eqrow > .cell, .grid > .cell { min-width: 0; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
.cell img { min-width: 0; max-width: 100%; max-height: 100%; }
.eqrow .cell .slotname { font-size: clamp(8px, 2.4vw, 10px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 1px; }
.eqrow .cell.empty { font-size: clamp(9px, 2.6vw, 11px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dgrid, .csgrid, .enhgrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.dgrid > *, .csgrid > *, .enhgrid > * { min-width: 0; }
.cs .nm, .cs .v { overflow: hidden; text-overflow: ellipsis; }
.scrollbtn { min-width: 0; } .scrollbtn span { min-width: 0; overflow-wrap: anywhere; } .scrollbtn img { flex: none; }
.spbox dl { grid-template-columns: auto minmax(0, 1fr); } .spbox dd { overflow-wrap: anywhere; }
.card h3, .card .ln, .cmp, .skrow .info, .statrow .ds, .muted { overflow-wrap: anywhere; }
.skrow .info, .statrow .ds { min-width: 0; }
.statrow .btn2 { flex: none; }
.row > .btn2 { flex-shrink: 1; min-width: 0; }
.tabs .btn2 { min-width: 0; }
@media (max-width: 380px) {
  .statrow { gap: 5px; } .statrow .nm { width: 40px; font-size: 14px; } .statrow .val { width: 50px; font-size: 14px; }
  .statrow .btn2 { padding: 6px 8px; }
  .btn2 { padding: 7px 9px; }
}

/* ===== 營地設施 ===== */
.mapcard { display: flex; gap: 8px; width: 100%; text-align: left; border: 1px solid #5a4428; border-radius: 9px; background: rgba(0,0,0,.35); padding: 7px; margin-bottom: 7px; color: var(--ink); min-width: 0; }
.mapcard.town { display: block; border-color: #7a6030; background: linear-gradient(#3a2a14, #1a120a); }
.mapcard.cur { border-color: #ffd86b; box-shadow: 0 0 8px rgba(255,216,107,.35); }
.mapcard.locked, .mapcard.soon { opacity: .55; }
.mapcard .mt { font-size: 15px; color: #f3d48a; } .mapcard .mt small { color: #b9a57c; font-size: 12px; }
.mthumb { position: relative; flex: none; width: 112px; height: 72px; border-radius: 6px; background: #1a120c center/cover; border: 1px solid #4a3620; overflow: hidden; }
.mthumb.none { background: radial-gradient(circle at 50% 60%, #3a2a1a, #0a0705); }
.mthumb .lk { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; background: rgba(0,0,0,.45); }
.mthumb .soon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #e8d8b0; background: rgba(0,0,0,.55); }
.mthumb .clr { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; text-align: center; color: #9dff9d; background: rgba(0,0,0,.6); }
.minfo { min-width: 0; flex: 1; } .minfo .ml { font-size: 12px; color: #c8b890; line-height: 1.45; overflow-wrap: anywhere; } .minfo .cond { color: #e8c070; }
.minfo .btn2 { margin-top: 4px; }
.chhead { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; color: var(--gold); }
.farnote { margin: 8px 0; padding: 7px 9px; border-radius: 7px; background: rgba(120,30,20,.4); color: #ffc0a8; font-size: 13px; }
.good { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #2c2012; min-width: 0; }
.good.dim { opacity: .5; } .good .gi { flex: 1; min-width: 0; } .good .gb { display: flex; gap: 4px; flex: none; }
.pot { width: 38px; height: 38px; flex: none; }
.price, .goldv { color: #ffd86b; } .price { font-size: 13px; }
.cell .price-tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; color: #ffd86b; background: rgba(0,0,0,.55); }
.bounty { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; background: linear-gradient(#e8d6a8, #c9b07a); color: #3a2410; margin-bottom: 6px; }
.bounty .muted { color: #6a5030; } .bounty .bp { flex: none; width: 46px; height: 46px; border: 2px solid #7a4a20; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #8a2a10; }
.bounty.done { filter: saturate(.6); } .bounty .g { color: #1a7a1a; }
.news { padding: 7px 0; border-bottom: 1px solid #2c2012; font-size: 13px; line-height: 1.5; }
.soonbox { text-align: center; padding: 20px 10px; } .soonbox .big { font-size: 46px; color: #c9a36a; }
/* HUD：互動、回營地、藥水 */
#actBtn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--sab)); padding: 10px 22px; border: 1px solid #c79a4a; border-radius: 22px; background: linear-gradient(#5a3a14, #24160a); color: #ffe6a8; font-size: 16px; box-shadow: 0 0 12px rgba(255,190,90,.45); animation: pulse 1.6s infinite; z-index: 5; }
#campBtn { position: absolute; left: calc(8px + var(--sal)); top: calc(96px + var(--sat)); padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(#2c1f14, #150e09); color: var(--gold); font-size: 13px; }
#potBtn { position: absolute; width: 50px; height: 50px; border-radius: 50%; border: 2px solid #8a6a35; background: radial-gradient(#3a2416, #140c07); display: flex; align-items: center; justify-content: center; padding: 0; }
#potBtn b { position: absolute; right: -4px; bottom: -4px; min-width: 18px; padding: 0 3px; border-radius: 9px; background: #222; border: 1px solid #8a6a35; font-size: 11px; color: #fff; }
#potBtn.empty { filter: grayscale(1) brightness(.6); }
#potBtn .pot { width: 36px; height: 36px; object-fit: contain; }
#potBtn .cd { position: absolute; inset: 2px; border-radius: 50%; background: conic-gradient(rgba(0,0,0,.7) calc(var(--p, 0) * 1turn), transparent 0); pointer-events: none; }
#potBtn .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: bold; text-shadow: 0 0 4px #000, 0 0 2px #000; pointer-events: none; }
#potBtn.oncd .pot { filter: saturate(.5) brightness(.8); }
.potrow { display: flex; gap: 6px; margin: 4px 0; }
.potc { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 1px solid #5a4326; border-radius: 8px; background: rgba(40,26,14,.6); font-size: 12px; }
.potc img { width: 44px; height: 44px; object-fit: contain; } .potc.dim { opacity: .45; } .potc small { color: #ccc; }
.good img.pot { width: 44px; height: 44px; object-fit: contain; flex: none; }
#locTag { position: absolute; left: calc(8px + var(--sal)); top: calc(96px + var(--sat)); color: #f0d898; font-size: 13px; text-shadow: 0 0 4px #000; pointer-events: none; }
#hud.town #skills, #hud.town #auto, #hud.town #bossArea, #hud.town #campBtn, #hud.town #potBtn { display: none !important; }
#hud:not(.town) #locTag { display: none; }

/* ===== 小地圖（右上）＋整張地圖 ===== */
#minimap { position: absolute; right: calc(6px + var(--sar)); top: calc(70px + var(--sat)); width: 100px; height: 100px; z-index: 3; }
#mmcv { position: absolute; left: 13%; top: 13%; width: 74%; height: 74%; border-radius: 50%; cursor: pointer; }
#minimap .mmframe { position: absolute; inset: 0; background: url(../assets/ui/minimap-frame.webp) center/100% no-repeat; pointer-events: none; }
#mmToggle { position: absolute; left: -2px; bottom: 2px; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1px solid #8a6a35; background: linear-gradient(#3a2816, #150e09); color: var(--gold); font-size: 14px; line-height: 20px; }
#mmOpen { position: absolute; right: calc(8px + var(--sar)); top: calc(70px + var(--sat)); width: 42px; height: 42px; padding: 0; border-radius: 50%; border: 2px solid #8a6a35; background: radial-gradient(#3a2416, #140c07); font-size: 20px; z-index: 3; }
#lootFeed { right: calc(112px + var(--sar)); }
#fullmap { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--sat)) 10px calc(10px + var(--sab)); }
.fmbox { width: min(94vw, 88vh, 640px); background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.7); }
.fmhead { display: flex; justify-content: space-between; align-items: center; color: var(--gold); font-size: 16px; padding: 2px 4px 6px; }
.fmhead button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #241810; color: var(--gold); }
#fmcv { position: static; display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 8px; border: 1px solid #3a2a16; }
.fmlegend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 7px 4px 2px; font-size: 12px; color: #d8c8a0; }
.fmlegend .lg { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; border-radius: 50%; }
.lg.me { background: #ffe08a; clip-path: polygon(100% 50%, 0 0, 30% 50%, 0 100%); border-radius: 0 !important; }
.lg.mob { background: #ff4a3a; } .lg.el { background: #7fe6ff; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border-radius: 0 !important; }
.lg.boss { background: #d0141a; outline: 1px solid #fff; } .lg.ws { background: #5fd0ff; transform: rotate(45deg) scale(.8); border-radius: 0 !important; }
.lg.prop { background: rgba(30,24,16,.9); outline: 1px solid rgba(225,205,160,.6); border-radius: 2px !important; }
/* 直向窄螢幕：小地圖放最右上，選單往下 */
@media (max-width: 600px) and (orientation: portrait) {
  #minimap { top: calc(4px + var(--sat)); width: 104px; height: 104px; right: 2px; }
  #mmOpen { top: calc(6px + var(--sat)); right: 10px; }
  #menu { top: calc(110px + var(--sat)); }
  #hud.mmoff #menu { top: calc(54px + var(--sat)); }
  #lootFeed { right: calc(64px + var(--sar)); top: calc(112px + var(--sat)); }
  #bossArea { top: calc(108px + var(--sat)); }
}

/* 設定：鏡頭遠近拉桿 */
.zoomrow { gap: 8px; align-items: center; margin: 2px 0 8px; }
.zoomrow input[type=range] { flex: 1; accent-color: #d9a441; height: 28px; }

/* ===== v10：封面／標題畫面 ===== */
#title { position: absolute; inset: 0; z-index: 35; overflow: hidden; background: #0b0710; touch-action: none; --cover: none; --cover-focus: 50% 62%; }
#title .tbg, #title .tbg-fill { position: absolute; inset: 0; background: var(--cover) var(--cover-focus) / cover no-repeat; }
#title .tbg-fill { display: none; }
#title:not(.hascover) .tbg, #title:not(.hascover) .tbg-fill { display: none; }
/* 備用封面（cover.webp 不存在時）：第一張地圖＋三位主角 */
#title .tfb { position: absolute; inset: 0; background: linear-gradient(rgba(16,10,30,.55), rgba(8,6,12,.2) 40%, rgba(8,6,6,.9)), url(../assets/thumbs/map1.webp?v=7) center 60% / cover no-repeat; display: flex; align-items: center; justify-content: center; gap: 2vmin; padding-top: 8vh; }
#title.hascover .tfb { display: none; }
#title .tfb i { width: 26vmin; height: 26vmin; max-width: 170px; max-height: 170px; border-radius: 50%; border: 3px solid #a4823f; background: #1a120c center/88% no-repeat; box-shadow: 0 0 24px rgba(0,0,0,.8), 0 0 12px rgba(255,200,110,.3); }
#title .tfb .c1 { background-image: url(../assets/ui/portrait.webp?v=7); transform: translateY(-4vmin) scale(1.12); z-index: 1; }
#title .tfb .c2 { background-image: url(../assets/ui/portrait-mage.webp?v=7); }
#title .tfb .c3 { background-image: url(../assets/ui/portrait-priest.webp?v=7); }
#title .tshade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(5,3,12,.35), rgba(0,0,0,0) 28%, rgba(0,0,0,0) 55%, rgba(6,4,6,.82) 82%); }
#title .tlogo { position: absolute; left: 0; right: 0; top: calc(15% + var(--sat)); text-align: center; pointer-events: none; }
#title .tlogo h1 { margin: 0; font-size: clamp(36px, 11vw, 64px); letter-spacing: .14em; color: #fbe7b0; text-shadow: 0 0 18px rgba(190,140,255,.75), 0 2px 0 #5b3a12, 0 4px 14px #000; font-weight: 900; }
#title .tlogo p { margin: 4px 0 0; color: #d9c9f2; font-size: clamp(13px, 3.6vw, 17px); letter-spacing: .3em; text-shadow: 0 1px 6px #000; }
#tmenu { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(5% + var(--sab)); width: min(82%, 340px); display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
.tbtn { min-height: 50px; border-radius: 12px; border: 1px solid #8d6c37; background: linear-gradient(#3b2a1a, #1b120b); color: #f6dfa6; font-size: 18px; letter-spacing: .2em; box-shadow: 0 3px 12px rgba(0,0,0,.6); }
.tbtn.gold { background: linear-gradient(#c79a4a, #7a5520); color: #fff4d6; border-color: #f0cf86; text-shadow: 0 1px 2px #3a2208; }
.tbtn.ghost { background: rgba(20,14,24,.65); border-color: #6f5a8a; color: #e6dcff; }
.tbtn:disabled { opacity: .4; }
.tbtn:active:not(:disabled) { transform: scale(.98); }
.tnote { margin: 2px 0 0; font-size: 13px; color: #d8cbb0; text-shadow: 0 1px 4px #000; line-height: 1.5; }
.tnote.warn { color: #ffcf8a; }
.tuser { margin: 4px 0 0; font-size: 14px; color: #e8dcc0; text-shadow: 0 1px 4px #000; }
.tuser a { color: #ffd98a; }
#title .tver { position: absolute; right: calc(8px + var(--sar)); bottom: calc(4px + var(--sab)); font-size: 11px; color: rgba(255,255,255,.35); }
/* 橫向：整張直式封面放左半邊，背景用同一張圖模糊填滿；標題和按鈕放右半邊 */
@media (min-aspect-ratio: 6/5) {
  #title.hascover .tbg { background-size: contain; background-position: 22% center; }
  #title.hascover .tbg-fill { display: block; filter: blur(22px) brightness(.45) saturate(1.2); transform: scale(1.15); }
  #title .tshade { background: linear-gradient(90deg, rgba(0,0,0,0) 35%, rgba(6,4,10,.55) 60%); }
  #title .tlogo { left: 48%; right: var(--sar); top: calc(12% + var(--sat)); }
  #title .tlogo h1 { font-size: clamp(32px, 6vw, 60px); }
  #tmenu { left: 48%; right: var(--sar); width: auto; transform: none; padding: 0 max(4%, 16px); bottom: auto; top: 42%; gap: 8px; max-width: 460px; margin-left: auto; }
  .tbtn { min-height: 42px; font-size: 16px; }
}
@media (min-aspect-ratio: 6/5) and (max-height: 430px) {
  #title .tlogo { top: calc(7% + var(--sat)); }
  #title .tlogo h1 { font-size: 34px; }
  #tmenu { top: 36%; gap: 6px; }
  .tbtn { min-height: 38px; }
}

/* 彈出視窗（登入、註冊、改密碼、存檔選擇） */
#modal { position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,.66); display: flex; align-items: center; justify-content: center; padding: calc(12px + var(--sat)) 14px calc(12px + var(--sab)); touch-action: pan-y; }
.mbox { width: min(100%, 380px); max-height: 100%; overflow-y: auto; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 16px 16px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.8); }
.mbox h3 { margin: 0 0 10px; color: var(--gold); font-size: 19px; text-align: center; letter-spacing: .1em; }
.mbox p { margin: 6px 0; font-size: 14px; color: #dccbaa; line-height: 1.6; }
.mform label { display: block; margin: 8px 0; font-size: 13px; color: #c4b08a; }
.mform input { display: block; width: 100%; margin-top: 4px; padding: 10px 11px; border-radius: 8px; border: 1px solid #6d5330; background: #120c08; color: #f2e4c4; font-size: 16px; }
.mform input:focus { outline: none; border-color: #e0b766; box-shadow: 0 0 0 2px rgba(224,183,102,.25); }
.mnote { font-size: 12px !important; color: #b9a37c !important; }
.merr { min-height: 1.2em; color: #ff8a7a !important; font-size: 13px !important; }
.mopts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mopts.row2 { flex-direction: row; }
.mopts.row2 .mbtn2 { flex: 1; }
.mbtn2 { min-height: 44px; border-radius: 9px; border: 1px solid var(--line); background: linear-gradient(#3a2817, #1c130b); color: var(--gold); font-size: 15px; padding: 8px 10px; line-height: 1.35; }
.mbtn2.gold { background: linear-gradient(#b88a3e, #6c4a1a); color: #fff3d2; border-color: #e6c27a; }
.mbtn2 small { display: block; font-size: 12px; opacity: .85; margin-top: 2px; }
.mbtn2:disabled { opacity: .5; }

/* 雲端同步狀態（小膠囊） */
#sync { position: absolute; left: calc(8px + var(--sal)); top: calc(128px + var(--sat)); display: flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(10,7,5,.55); color: #cfc2a5; font-size: 11px; line-height: 16px; z-index: 4; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sync i { width: 7px; height: 7px; border-radius: 50%; background: #888; flex: none; }
#sync[data-s=synced] i { background: #6fdc7a; }
#sync[data-s=pending] i, #sync[data-s=syncing] i { background: #f3c25a; }
#sync[data-s=syncing] i { animation: pulse 1s infinite; }
#sync[data-s=offline] i, #sync[data-s=error] i { background: #ff8a5a; }
#sync[data-s=conflict] i, #sync[data-s=expired] i { background: #ff4f4f; }
#sync[data-s=guest] i, #sync[data-s=noserver] i { background: #9aa0b8; }
.acctbox { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.25); margin-bottom: 6px; }
