:root {
  --panel: rgba(15, 18, 27, .88);
  --panel-solid: #141824;
  --bar-h: 208px;   /* 2026-11-03 拉高約 30%,原本 160 */
  --cell: 44px;
  --hk: 50px;
  --line: #6e5630;
  --gold: #e8c374;
  --ink: #f0e9d8;
  --mute: #a39c8b;
  --hp: #d8433f;
  --mp: #3f86e0;
  --xp: #b58cf0;
  --sans: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  --serif: "Noto Serif TC", "PMingLiU", "Songti TC", serif;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: #0c0f16; color: var(--ink); font: 14px/1.5 var(--sans); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
canvas#game-text { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }   /* 畫質中、低時的名字和數字(render.js textLayer) */

/* 共用的石板銅框 */
.frame { background: #26221d var(--stone); border: 1px solid #0d0a07; border-radius: 4px; box-shadow: inset 0 0 0 1px #8a6a32, inset 0 0 0 3px #15110c, 0 4px 16px rgba(0, 0, 0, .55); }

/* HUD:底部一整條介面列,遊戲畫面只畫在它上方 */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > *, #hud button, #chatin { pointer-events: auto; }

.unit-name { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; line-height: 1.2; margin-bottom: 4px; }
.bar { position: relative; height: 15px; background: #0a0c12; border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .12s linear; }
.bar b { position: absolute; inset: 0; text-align: center; font: 600 11px/15px var(--sans); text-shadow: 0 1px 1px #000; }
.bar.hp i { background: linear-gradient(#ea5f58, var(--hp)); }
.bar.mp i { background: linear-gradient(#62a2ee, var(--mp)); }
.bar.boss { height: 18px; }
.bar.boss b { line-height: 18px; }
.bar.boss i { background: linear-gradient(#ff8a3c, #c22b1e); }

#target { position: absolute; left: 12px; top: 12px; width: 240px; padding: 8px 10px; }
#bossbar { position: absolute; left: 50%; top: 12px; width: min(420px, 40vw); transform: translateX(-50%); text-align: center; }
#boss-name { font: 700 15px var(--serif); color: #ffb13b; text-shadow: 0 1px 3px #000; }

#side { position: absolute; right: 12px; top: 12px; width: 190px; display: flex; flex-direction: column; gap: 6px; }
#mini { width: 190px; height: 190px; border: 1px solid var(--line); background: #0a0c12; transform: rotate(45deg) scale(0.72); }
#boss-timer { text-align: center; font-size: 12px; color: #ffb78a; text-shadow: 0 1px 2px #000; }
#net-tag { text-align: center; font-size: 11px; color: #c8c0b0; text-shadow: 0 1px 2px #000; }
#q-tag { margin-top: -4px; text-align: center; font-size: 11px; color: #a89c84; text-shadow: 0 1px 2px #000; cursor: pointer; }
#q-tag:hover { color: var(--gold); }
#tracker { padding: 8px 10px; font-size: 13px; }
#tracker h3 { font: 700 13px var(--sans); color: var(--gold); margin-bottom: 2px; }
#tracker p { color: var(--mute); }
#tracker p.done { color: #8fe08f; }

#bar { position: absolute; left: 0; right: 0; bottom: 0; height: var(--bar-h); display: grid; grid-template-columns: 192px minmax(0, 1fr) 216px; grid-template-rows: minmax(0, 1fr); background: #26221d var(--stone); border-top: 2px solid #a07a38; box-shadow: 0 -2px 0 #120d08, 0 -6px 14px rgba(0, 0, 0, .5); }

#st { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-right: 2px solid #120d08; box-shadow: 1px 0 0 #5a4526; }
#zone-name { position: absolute; left: 8px; bottom: calc(100% + 8px); font: 700 14px var(--serif); color: #7fd0ff; text-shadow: 0 1px 3px #000, 0 0 2px #000; white-space: nowrap; }
.gauge { position: relative; overflow: hidden; }
.gauge i { position: absolute; inset: 0 auto 0 0; }
.gauge b, .gauge em { position: relative; }
#st-lv, #st-lv2 { display: flex; justify-content: space-between; align-items: center; height: 24px; padding: 0 8px; background: #100d0a; border: 1px solid #5a4526; border-radius: 12px; font: 700 13px var(--sans); text-shadow: 0 1px 2px #000; }
#st-lv i, #st-lv2 i { background: linear-gradient(#6a4fa0, #3f2c6a); }
#my-name { overflow: hidden; padding-left: 8px; font: 700 13px var(--serif); color: var(--gold); text-overflow: ellipsis; white-space: nowrap; }
.st-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.chip { display: flex; justify-content: space-between; align-items: center; height: 22px; padding: 0 6px; background: #100d0a; border: 1px solid #5a4526; border-radius: 4px; font-size: 12px; }
.chip em { font-style: normal; color: var(--mute); }
.chip b { font-weight: 700; }
#st-bag-fill { background: linear-gradient(#b5752a, #7a4a14); }
#my-gold { color: var(--gold); font-weight: 700; }
#day { position: relative; height: 14px; margin-top: auto; border: 1px solid #5a4526; border-radius: 7px; overflow: hidden; background: linear-gradient(90deg, #6fb7e8 0 48%, #e8a25a 55%, #12183a 62% 88%, #e8a25a 95%, #6fb7e8); }
#day-sun { position: absolute; top: 2px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #ffd34a; box-shadow: 0 0 5px #ffd34a; }
#day-sun.moon { background: #dfe6ff; box-shadow: 0 0 5px #dfe6ff; }

#mid { display: flex; flex-direction: column; min-width: 0; }
#vitals { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 56px; padding: 5px 8px 4px; }
#vitals .bar { height: 20px; margin: 0; border: 1px solid #a07a38; border-radius: 2px; box-shadow: inset 0 0 0 1px #000; }
#vitals .bar b { font: 700 12px/18px var(--sans); }
#vitals .bar.hp i { background: linear-gradient(#e0483e, #8e1712); }
#vitals .bar.mp i { background: linear-gradient(#4a78d8, #1d3a8a); }
#crest { position: absolute; left: 50%; top: -14px; width: 96px; height: 44px; margin-left: -48px; filter: drop-shadow(0 2px 2px #000); }
#chat { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 8px 6px; background: #191613 var(--scale); border: 1px solid #5a4526; box-shadow: inset 0 0 8px #000; }
#chat { position: relative; }
#log { flex: 1; min-height: 0; overflow-y: scroll; overscroll-behavior: contain; padding: 4px 8px; font-size: 13px; line-height: 1.45; scrollbar-width: auto; scrollbar-color: #8a6a32 #120f0b; overflow-wrap: anywhere; }
#log-new { position: absolute; right: 22px; bottom: 30px; padding: 1px 10px; background: #3a2a12; border: 1px solid var(--gold); border-radius: 10px; color: #ffe58a; font-size: 12px; cursor: pointer; }
#log .from { font-weight: 700; }
#log .ai { color: var(--mute); font-size: 11px; margin-left: 3px; }
#chat-row { display: flex; }
#chat-mode { flex: none; padding: 0 8px; background: rgba(0, 0, 0, .55); border: 0; border-top: 1px solid #5a4526; border-right: 1px solid #5a4526; color: var(--ink); font-size: 12px; cursor: pointer; }
#chat-mode.on { color: #7fe0ff; }
#log .chat-tag { margin-right: 4px; color: #7fe0ff; font-size: 12px; }
#log .chat-party { color: #bfefff; }
#log .chat-all { color: #ffe2a8; }
#log .chat-all .chat-tag { color: #ffb84a; }
#log .chat-trade { color: #ffc6e6; }
#log .chat-trade .chat-tag { color: #ff7ac0; }
#log .chat-tell { color: #dcc6ff; }
#log .chat-tell .chat-tag { color: #b98aff; }
#log .from { cursor: pointer; }
#log .chat-say .chat-tag { color: #d8d0bc; }
#log [data-ch="sys"] .chat-tag { color: inherit; }
/* 聊天分頁:亮的才顯示那個頻道,反灰的不顯示 */
#chat-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 2px 4px 0; background: rgba(0, 0, 0, .4); border-bottom: 1px solid #5a4526; }
#chat-tabs button { height: 18px; padding: 0 9px; background: #3a2f1c; border: 1px solid #8a6a32; border-bottom: 0; border-radius: 3px 3px 0 0; color: #ffe58a; font: 600 12px/16px var(--sans); }
#chat-tabs button.off { background: #15120e; border-color: #3a3024; color: #6e6456; }
#chat-tabs button:hover { border-color: var(--gold); }
#log.hide-sys [data-ch="sys"], #log.hide-say [data-ch="say"], #log.hide-party [data-ch="party"], #log.hide-clan [data-ch="clan"], #log.hide-all [data-ch="all"], #log.hide-trade [data-ch="trade"], #log.hide-tell [data-ch="tell"] { display: none; }
#chat-mode[data-ch="all"] { color: #ffb84a; }
#chat-mode[data-ch="trade"] { color: #ff7ac0; }
#chat-mode[data-ch="party"] { color: #7fe0ff; }
#party { position: absolute; left: 12px; top: 96px; width: 190px; padding: 6px 8px; font-size: 12px; }
#party header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; color: var(--gold); }
#party-quit { padding: 0 6px; background: #0e0c09; border: 1px solid #5a4526; border-radius: 3px; color: var(--ink); font-size: 12px; cursor: pointer; }
#party-loot { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; color: var(--mute); white-space: nowrap; }
#party-mode { flex: 1; min-width: 0; padding: 1px 2px; background: #0e0c09; color: var(--ink); border: 1px solid #5a4526; border-radius: 3px; font-size: 12px; }
#party-mode:disabled { opacity: .7; }
.pm { padding: 3px 4px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; }
.pm:hover { background: rgba(255, 255, 255, .06); }
.pm.focus { border-color: #58d8ff; }
.pm.dead { opacity: .5; }
.pm b { display: block; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.pm-bar { height: 5px; margin-top: 2px; overflow: hidden; background: rgba(0, 0, 0, .7); border-radius: 2px; }
.pm-bar i { display: block; height: 100%; }
.pm-bar.hp i { background: #58c05a; }
.pm-bar.mp i { background: #4f8fe0; }
#party-ask { position: absolute; left: 50%; top: 70px; z-index: 7; padding: 10px 14px; transform: translateX(-50%); text-align: center; }
#party-ask p { margin-bottom: 8px; }
#party-ask .row { justify-content: center; }
#trade-ask { position: absolute; left: 50%; top: 130px; z-index: 7; padding: 10px 14px; transform: translateX(-50%); text-align: center; }
#trade-ask p { margin-bottom: 8px; }
#trade-ask .row { justify-content: center; }
#pmenu { position: fixed; z-index: 8; min-width: 130px; padding: 6px; }
#pmenu h4 { margin-bottom: 4px; padding: 0 4px; font-size: 13px; }
#pmenu button { display: block; width: 100%; padding: 4px 6px; background: none; border: 0; border-radius: 3px; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer; }
#pmenu button:hover { background: rgba(255, 255, 255, .1); }
#chatin { width: 100%; padding: 3px 8px; background: rgba(0, 0, 0, .55); border: 0; border-top: 1px solid #5a4526; outline: none; }
#chatin:focus { background: rgba(0, 0, 0, .8); }

#keys { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0 2px; border-left: 2px solid #120d08; box-shadow: inset 1px 0 0 #5a4526; }
#hk-qwer { display: grid; grid-template-columns: repeat(4, var(--hk)); margin-bottom: 1px; background: #0e0c09; border: 1px solid #a07a38; }
#hk-pages { display: flex; gap: 2px; align-self: flex-start; margin-left: 7px; }
#hk-pages button { width: 34px; height: 17px; padding: 0; background: #17130e; border: 1px solid #5a4526; border-bottom: 0; border-radius: 4px 4px 0 0; font: 700 12px/15px var(--sans); color: var(--mute); }
#hk-pages button:hover { color: var(--ink); }
#hk-pages button.on { background: #3a2f1c; border-color: var(--gold); color: #ffe58a; }
#hk-grid { display: grid; grid-template-columns: repeat(4, var(--hk)); background: #0e0c09; border: 1px solid #6e5630; }
.hk { position: relative; width: var(--hk); height: var(--hk); overflow: hidden; box-shadow: inset 0 0 0 1px #2d261c; user-select: none; touch-action: none; cursor: pointer; }
.hk:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.hk .cell { position: absolute; inset: 1px; width: auto; height: auto; border: 0; }
.hk kbd { position: absolute; inset: 0; display: grid; place-items: center; font: 700 19px var(--serif); color: #3b3327; pointer-events: none; }
.hk.full kbd { inset: 0 auto auto 3px; display: block; font: 700 12px var(--sans); color: #fff; text-shadow: 0 0 3px #000, 0 1px 2px #000; }
.hk .cd { position: absolute; inset: auto 0 0 0; height: 0; background: rgba(0, 0, 0, .72); pointer-events: none; }
.hk.nomp img { filter: saturate(.25) brightness(.65); }
.hk.none img { filter: grayscale(1) brightness(.5); }
.hk.fire { animation: pop .18s ease-out; }
@keyframes pop { 50% { transform: scale(.9); } }

#menu { display: flex; gap: 2px; width: calc(var(--hk) * 4 + 2px); margin-top: 1px; }
#menu button { display: grid; place-items: center; flex: 1; min-width: 0; height: 23px; padding: 0; background: #17130e; border: 1px solid #5a4526; border-radius: 3px; color: var(--gold); }
#menu button:hover { border-color: var(--gold); background: #2d2518; }
#menu svg { width: 15px; height: 15px; fill: var(--gold); }

/* 角色、道具、技能視窗:可以同時開著邊打怪邊看 */
.win { position: fixed; top: 10px; z-index: 5; display: flex; flex-direction: column; max-height: calc(100vh - var(--bar-h) - 20px); padding: 8px 9px 9px; }
.win header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; cursor: move; touch-action: none; user-select: none; }
.win h3 { font: 700 15px var(--serif); color: var(--gold); }
.win-close { padding: 0 6px; background: #17130e; border: 1px solid #5a4526; border-radius: 3px; font-size: 12px; color: var(--ink); }
.win-close:hover { border-color: var(--gold); }
.win footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; padding: 3px 8px; background: #100d0a; border: 1px solid #5a4526; font-size: 12px; }
#win-char { left: 10px; width: 338px; overflow-y: auto; scrollbar-width: thin; }
#win-bag { right: 10px; }
#win-skill { right: 358px; }
#bag-body { display: flex; gap: 6px; min-height: 0; }
#bag-worn { flex: none; display: grid; grid-template-columns: repeat(2, var(--cell)); grid-auto-rows: var(--cell); align-content: start; min-height: 0; overflow-y: auto; background: #0e0c09; border: 1px solid #6e5630; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }   /* 畫面很矮時(手機橫拿)跟著捲,不會超出視窗 */
#bag-worn .cell:empty::after { content: attr(data-label); position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #6e6456; }
#bag-sort { margin: 0 auto 0 6px; padding: 0 6px; background: #17130e; border: 1px solid #5a4526; border-radius: 3px; font-size: 12px; color: var(--gold); }
#bag-sort:hover { border-color: var(--gold); }
/* 交易:左邊對方、右邊自己,都按確定才成交 */
#win-trade { left: max(6px, calc(50% - 235px)); width: min(470px, calc(100vw - 12px)); top: 60px; }
@media (max-width: 1100px) { #win-trade { left: 6px; top: 10px; } }   /* 畫面窄時靠左,右邊的道具欄才不會被蓋住 */
#trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trade-side { display: flex; flex-direction: column; min-width: 0; padding: 6px; background: #0e0c09; border: 1px solid #6e5630; }
.trade-side h4 { margin-bottom: 4px; font-size: 13px; color: var(--gold); }
.trade-side.ok { border-color: #7fe08a; box-shadow: inset 0 0 0 1px #7fe08a; }
.trade-list { display: flex; flex-direction: column; gap: 2px; min-height: 150px; max-height: 260px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }
.trade-row { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 3px; font-size: 12px; }
.trade-row img { flex: none; width: 30px; height: 30px; }
.trade-row b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.trade-row input { width: 52px; padding: 1px 3px; background: #17130e; border: 1px solid #5a4526; border-radius: 3px; }
.trade-row.mine { cursor: pointer; }
.trade-row.mine:hover { background: #2a1e10; }
.trade-gold { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--gold); }
.trade-gold input { flex: 1; min-width: 0; padding: 2px 4px; background: #17130e; border: 1px solid #5a4526; border-radius: 3px; }
.trade-state { margin-top: 4px; font-size: 12px; color: var(--mute); }
.trade-side.ok .trade-state { color: #7fe08a; }
#trade-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
#trade-foot p { flex: 1; margin: 0; font-size: 12px; color: var(--mute); }
/* 2026-11-04 卡冊:照地圖分組的大卡片 */
#win-cards { left: max(6px, calc(50% - 270px)); width: min(540px, calc(100vw - 12px)); }
#win-cards h3 small { margin-left: 6px; font: 600 12px var(--sans); color: var(--mute); }
#cards-sum { margin: 0 0 5px; font-size: 12px; }
#cards-body { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }
#win-cards footer { display: block; line-height: 1.45; }
.album-group { margin-bottom: 6px; padding: 5px 6px 6px; background: #0e0c09; border: 1px solid #4a3a22; }
.album-group.done { border-color: #a88a42; box-shadow: inset 0 0 0 1px rgba(232, 195, 116, .25); }
.album-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 4px; font-size: 13px; }
.album-head b { color: var(--gold); }
.album-head small { flex-basis: 100%; font-size: 12px; }
.album-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.album-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; text-align: center; }
.album-cell small { font-size: 11px; }
.album-put { width: 100%; padding: 2px 0; font-size: 12px; }
/* 一張卡:外框是等級的顏色,裡面是地圖的顏色 */
.cardf { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 92px; aspect-ratio: 3 / 4; padding: 4px; border-radius: 7px; background: linear-gradient(#4aa3ff, #1a1a22); box-shadow: 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .5); }
.cardf.r3 { background: linear-gradient(#c56bff, #1a1a22); }
.cardf.r4 { background: linear-gradient(#ffb13b, #1a1a22); }
.cardf::before { content: ''; position: absolute; inset: 4px; border-radius: 4px; background: var(--tint, linear-gradient(#8fd068, #24461a)); }
.cardf.g-forest { --tint: linear-gradient(#5a9a62, #0e2416); }
.cardf.g-desert { --tint: linear-gradient(#e8c47e, #5a3812); }
.cardf.g-snow { --tint: linear-gradient(#c4e2f6, #28486a); }
.cardf.g-lava { --tint: linear-gradient(#f08a5a, #4a1008); }
.cardf.g-boss { --tint: linear-gradient(#ffd878, #5a2c04); }
.cardf-pic { position: relative; width: 100%; aspect-ratio: 1; margin-top: 8%; }
.cardf-name { position: relative; margin-top: auto; padding: 1px 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 3px; background: rgba(10, 8, 6, .72); font: 700 11px var(--sans); color: #fff3d0; }
.cardf.none { background: linear-gradient(#4a4a52, #1a1a22); }
.cardf.none::before { background: linear-gradient(#3a3a40, #141418); }
.cardf.none .cardf-pic { filter: brightness(0) opacity(.45); }
.cardf.none .cardf-name { color: #8a8478; }
.cardf.have { opacity: .9; }
.cardf.have .cardf-pic { filter: saturate(.55); }
#tip .cardf, .tc-box .cardf { width: 110px; max-width: 110px; margin: 0 auto 6px; }
.cq-row .btn { flex: none; }

#win-afk { right: 262px; width: 248px; overflow-y: auto; scrollbar-width: thin; }
@media (max-width: 600px) { #win-afk { right: 10px; } }   /* 手機直拿:放在道具欄的位置,才不會跑到畫面外 */
#afk-toggle { margin-bottom: 6px; }
#afk-toggle.on { border-color: var(--gold); color: var(--gold); }
#afk-note { margin: 0 0 6px; color: var(--mute); font-size: 12px; line-height: 1.45; }
#afk-form h4 { margin: 8px 0 4px; color: var(--gold); font-size: 13px; }
.afk-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
.afk-row span { flex: 1; min-width: 0; }
.afk-row input { width: 62px; padding: 2px 4px; text-align: right; }
.afk-row input, #title-own input { background: #0e0c09; color: var(--ink); border: 1px solid #5a4526; border-radius: 3px; }
.afk-row input:focus, #title-own input:focus { border-color: var(--gold); outline: none; }
.afk-row input:disabled { opacity: .45; }
.afk-row em { width: 16px; font-style: normal; color: var(--mute); }
.afk-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--gold); }
.afk-slot { width: 100%; margin-bottom: 4px; padding: 3px 4px; background: #0e0c09; color: var(--ink); border: 1px solid #5a4526; border-radius: 3px; font-size: 13px; }
.afk-slot:focus { border-color: var(--gold); outline: none; }
#afk-tag, #speed-tag { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); padding: 3px 12px; background: rgba(16, 13, 10, .82); border: 1px solid #5a4526; border-radius: 4px; color: var(--gold); font-size: 13px; white-space: nowrap; pointer-events: none; }
#speed-tag { top: 36px; }
.cells { display: grid; grid-template-columns: repeat(5, var(--cell)); grid-auto-rows: var(--cell); flex: 0 1 auto; min-height: 0; max-height: calc(var(--cell) * 8 + 2px); overflow-y: auto; background: #0e0c09; border: 1px solid #6e5630; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }
#skill-cells { grid-template-columns: repeat(4, var(--cell)); max-height: calc(var(--cell) * 5 + 2px); }
.cell { position: relative; width: var(--cell); height: var(--cell); box-shadow: inset 0 0 0 1px #2d261c; user-select: none; -webkit-touch-callout: none; }
.cell img { display: block; width: 100%; height: 100%; }
.cell small { position: absolute; right: 2px; bottom: 0; font: 700 11px var(--sans); color: #ffe58a; text-shadow: 0 0 3px #000, 0 1px 2px #000; pointer-events: none; }
.cell[data-ref] { cursor: grab; box-shadow: inset 0 0 0 1px var(--rar, #2d261c); }
.cell[data-ref]:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.cell.low img { filter: saturate(.3) brightness(.6); }
.cell.locked img { filter: grayscale(1) brightness(.45); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 30; width: 44px; height: 44px; opacity: .85; pointer-events: none; }
#tip { position: fixed; z-index: 40; max-width: 280px; padding: 8px 11px; font-size: 13px; pointer-events: none; }
#tip h4 { font: 700 14px var(--sans); margin-bottom: 2px; }
#tip .hint { margin-top: 3px; }
#tip.two:not([hidden]) { display: flex; flex-wrap: wrap; gap: 8px 12px; width: 580px; max-width: calc(100vw - 12px); }
.tip-card { flex: 1 1 260px; min-width: 0; }
.tip-card + .tip-card { border-left: 1px solid rgba(255, 255, 255, .14); padding-left: 12px; }
.tip-card .hint:first-child { margin: 0 0 4px; }
/* 手機平板用手指點的卡片(ui.js 的 openCard):蓋一層半透明,點外面關掉,按鈕要夠大 */
#tcard { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 8px; background: rgba(0, 0, 0, .4); }
#tcard[hidden] { display: none; }
.tc-box { display: flex; flex-direction: column; width: min(330px, 100%); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 10px 12px; font-size: 13px; }
.tc-box.two { width: min(600px, 100%); }
.tc-box h4 { font: 700 14px var(--sans); margin-bottom: 2px; }
.tc-box .hint { margin-top: 3px; }
/* 內容太長就在卡片裡捲,按鈕一直留在最下面看得到 */
.tc-body { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }
.tc-body.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 12px; }
.tc-acts { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.tc-acts .btn { min-width: 92px; min-height: 42px; font-size: 15px; }
.tc-acts .btn:disabled { opacity: .5; }
.tc-box.more .tc-acts::before { content: '往下滑看更多 ▼'; flex-basis: 100%; text-align: center; font-size: 12px; color: var(--mute); }
@media (max-width: 520px) {
  .tc-body.two .tip-card + .tip-card { border-left: 0; padding-left: 0; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .14); }
}
/* 按了「放到快捷鍵」:格子發亮等著點;視窗先藏起來,才不會蓋住快捷鍵(手機直拿的技能視窗、手機橫拿的道具欄),放好再出現 */
body.placing .hk { animation: hk-wait 1s ease-in-out infinite; }
body.placing .win, body.placing #panel { visibility: hidden; }
@keyframes hk-wait { 50% { box-shadow: inset 0 0 0 2px var(--gold); } }
/* 商店、倉庫清單裡的「數值」按鈕只給手指用 */
.tinfo { flex: none; padding: 6px 10px; }
body:not(.touch) .tinfo { display: none; }
/* 交易說明:滑鼠和手指各一句 */
.for-touch { display: none; }
body.touch .for-touch { display: inline; }
body.touch .for-mouse { display: none; }

#char-top { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
#char-stats { display: flex; flex-direction: column; gap: 1px; }
#char-stats hr { margin: 3px 0; border: 0; border-top: 1px solid #5a4526; }
#char-stats p { margin-top: 2px; font-size: 12px; }
.kv { display: flex; align-items: center; gap: 6px; height: 23px; font-size: 13px; }
.kv em { flex: none; width: 34px; font-style: normal; color: var(--mute); }
.kv b { font-weight: 700; }
.kv .stat-btn { width: 22px; height: 20px; margin-left: auto; font-size: 12px; line-height: 1; }
#doll { position: relative; overflow: hidden; display: grid; grid-template-areas: "cape helm neck" "weapon armor off" "gloves . ring" ". boots ."; grid-template-columns: repeat(3, var(--cell)); grid-template-rows: repeat(4, var(--cell)); gap: 6px 4px; justify-content: center; align-content: center; padding: 8px 0; background: radial-gradient(ellipse at 50% 45%, #6a6156, #2a2520 80%); border: 1px solid #5a4526; }
#doll > img { position: absolute; left: 50%; top: 50%; width: 230px; height: 230px; margin: -112px 0 0 -115px; filter: brightness(0); opacity: .6; pointer-events: none; }
#doll .cell { background: rgba(10, 8, 6, .62); }
#doll .cell:empty::after { content: attr(data-label); position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #6e6456; }
#char-more { margin-top: 6px; }
#title-now { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; font-size: 13px; }
#title-now .btn { margin-left: auto; padding: 2px 10px; }
.title-own { color: #c9a6ff; }
#title-now .title-sum { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; }
#title-own { display: flex; gap: 6px; margin-bottom: 6px; }
#title-own input { flex: 1; min-width: 0; }
#title-own .btn { white-space: nowrap; padding: 4px 10px; }
#title-list h4 { margin: 8px 0 4px; color: var(--gold); font-size: 13px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); font-size: 13px; }
.title-row small { display: block; color: var(--mute); font-size: 12px; }
.title-row .btn { padding: 2px 10px; white-space: nowrap; }
.title-row > span { white-space: nowrap; font-size: 12px; }
.title-row.locked b { color: var(--mute); }
.chat-title { color: #e8c374; }
.chat-title.own { color: #c9a6ff; }
#char-more .stats { grid-template-columns: repeat(3, 1fr); gap: 1px 8px; margin-bottom: 6px; font-size: 12px; }
#char-more .set-line { margin-bottom: 3px; }

#banner { position: fixed; left: 0; right: 0; top: 22%; text-align: center; pointer-events: none; opacity: 0; transition: opacity .5s; font: 700 34px var(--serif); color: var(--gold); text-shadow: 0 2px 10px rgba(0, 0, 0, .85); }
#banner.show { opacity: 1; }
#banner small { display: block; font: 400 15px var(--sans); color: var(--ink); }
#toasts { position: fixed; left: 50%; top: 66%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#toasts div { display: flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 6px; background: rgba(10, 12, 18, .78); animation: fade 2.8s forwards; }
#toasts img { width: 30px; height: 30px; }
@keyframes fade { 80% { opacity: 1; } 100% { opacity: 0; } }

/* 面板 */
#panel { position: fixed; z-index: 6; left: 50%; top: calc((100vh - var(--bar-h)) / 2); transform: translate(-50%, -50%); width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - var(--bar-h) - 20px); display: flex; flex-direction: column; }
#panel header { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
#panel h2 { font: 700 18px var(--serif); color: var(--gold); }
#panel-close { width: 32px; height: 32px; border: 0; background: none; font-size: 22px; color: var(--mute); }
#panel-close:hover { color: var(--ink); }
#panel-body { padding: 14px; overflow-y: auto; }
#panel-body p { margin-bottom: 8px; }
.btn { padding: 7px 14px; background: #2a2f3e; border: 1px solid var(--line); border-radius: 6px; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: #7a5a22; border-color: var(--gold); color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 8px; }
.gold { color: var(--gold); }
.muted { color: var(--mute); }

.bag-top { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.gear-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(2, auto); gap: 0 14px; justify-content: start; font-size: 13px; color: var(--mute); }
.stats b { color: var(--ink); font-weight: 600; }
.item { position: relative; width: 48px; height: 48px; border-radius: 6px; background: #1d2230; border: 2px solid #333a4a; display: grid; place-items: center; padding: 0; overflow: hidden; }
.item img { display: block; width: 100%; height: 100%; }
.item.empty { color: #4a5062; cursor: default; font: 400 11px var(--sans); }
.item.sel { outline: 2px solid var(--gold); outline-offset: 1px; }
.item small { position: absolute; right: 2px; bottom: 0; font: 700 11px var(--sans); color: #ffe58a; text-shadow: 0 0 3px #000, 0 1px 2px #000; }
.mini-icon { width: 32px; height: 32px; }
.npc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.npc-head img { width: 52px; height: 52px; border-radius: 8px; border: 1px solid var(--line); }
.detail-info { display: flex; gap: 10px; margin-bottom: 6px; }
.detail-info img { flex: none; width: 56px; height: 56px; border-radius: 8px; background: #141824; }
.detail-info p { margin-bottom: 0; }
.shop-tip { margin: 4px 0 6px; font-size: 13px; }
.shop-list { max-height: min(50vh, 440px); overflow-y: auto; background: #0e0c09; border: 1px solid #6e5630; scrollbar-width: thin; scrollbar-color: #6e5630 #120f0b; }
.shop-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid #2d261c; cursor: pointer; user-select: none; }
.shop-row:hover { background: #1c1712; }
.shop-row.on { background: #3a2a12; box-shadow: inset 3px 0 0 var(--gold); }
.shop-row img { flex: none; width: 36px; height: 36px; }
.shop-name { flex: 1; min-width: 0; }
.shop-name b, .shop-name small { display: block; }
.shop-name small { color: var(--mute); font-size: 12px; }
.shop-row.low small { color: #ff8a7a; }
.shop-price { flex: none; color: var(--gold); white-space: nowrap; }
.shop-qty { flex: none; width: 56px; padding: 2px 4px; background: #0e0c09; color: var(--ink); border: 1px solid #5a4526; border-radius: 3px; text-align: right; }
.shop-qty:focus { border-color: var(--gold); outline: none; }
.shop-empty { padding: 14px; text-align: center; }
.shop-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.shop-foot .grow { flex: 1; }
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 6px; }
.detail { margin-top: 12px; padding: 10px; min-height: 96px; background: #1b1f2c; border-radius: 8px; }
.detail h4 { font: 700 15px var(--sans); }

.help-keys { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.help-keys kbd { color: var(--gold); font: 600 13px var(--sans); }

/* 登入 */
#login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: #0b1020; }
.login-sky { position: fixed; inset: 0; background:
  radial-gradient(2px 2px at 12% 22%, #fff, transparent), radial-gradient(1.5px 1.5px at 28% 62%, #dfe9ff, transparent),
  radial-gradient(2px 2px at 44% 16%, #fff, transparent), radial-gradient(1.5px 1.5px at 62% 42%, #fff, transparent),
  radial-gradient(2px 2px at 78% 26%, #ffe9c2, transparent), radial-gradient(1.5px 1.5px at 88% 68%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 7% 78%, #dfe9ff, transparent), radial-gradient(2px 2px at 52% 84%, #fff, transparent),
  radial-gradient(ellipse 90% 60% at 50% 115%, #7a3b2e, transparent), linear-gradient(#0b1020, #1a1b38 60%, #3a2440); }
#login-form { position: relative; width: min(560px, 100%); padding: 22px 24px; background: rgba(15, 18, 27, .9); border: 1px solid var(--line); border-radius: 12px; }
#login h1 { font: 700 40px/1.1 var(--serif); letter-spacing: .12em; text-align: center; color: var(--gold); }
.sub { text-align: center; letter-spacing: .35em; font-size: 11px; color: var(--mute); }
#online-count { text-align: center; color: var(--mute); font-size: 13px; margin: 2px 0 10px; }
#auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
#auth-tabs button { padding: 8px; background: #2a2f3e; border: 1px solid var(--line); border-radius: 6px; color: var(--mute); }
#auth-tabs button:hover { border-color: var(--gold); }
#auth-tabs button.on { background: #7a5a22; border-color: var(--gold); color: #fff; font-weight: 700; }
#auth-hint { margin-bottom: 4px; line-height: 1.5; }
#login-form label { display: block; margin-bottom: 8px; color: var(--mute); font-size: 13px; }
#login-form input { display: block; width: 100%; margin-top: 2px; padding: 8px 10px; background: #0d1018; border: 1px solid var(--line); border-radius: 6px; outline: none; }
#login-form input:focus { border-color: var(--gold); }
.login-box { position: relative; width: min(680px, 100%); padding: 18px 22px; background: rgba(15, 18, 27, .93); border: 1px solid var(--line); border-radius: 12px; }
.login-box h2 { font: 700 26px/1.2 var(--serif); letter-spacing: .08em; text-align: center; color: var(--gold); }
.login-box label { display: block; color: var(--mute); font-size: 13px; }
.login-box input { display: block; width: 100%; margin-top: 2px; padding: 8px 10px; background: #0d1018; border: 1px solid var(--line); border-radius: 6px; outline: none; }
.login-box input:focus { border-color: var(--gold); }
.login-actions { display: flex; gap: 8px; justify-content: flex-end; }
.login-actions .btn.primary { min-width: 120px; }
#chars-out { margin-right: auto; }
#char-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 8px; }
.char-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 210px; padding: 10px 6px; background: #1b1f2c; border: 2px solid #333a4a; border-radius: 10px; }
.char-slot:hover { border-color: var(--gold); }
.char-slot.sel { border-color: var(--gold); background: #292a2c; }
.char-slot.empty { border-style: dashed; background: rgba(27, 31, 44, .5); color: var(--mute); }
.char-slot img { display: block; width: 120px; height: 120px; }
.char-slot i { font: 300 52px/1 var(--sans); color: var(--gold); }
.char-slot b { font: 700 17px var(--serif); margin-top: 4px; max-width: 100%; overflow-wrap: anywhere; }
.char-slot em { font-style: normal; font-size: 12px; color: var(--gold); }
.char-tool { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 6px; }
.char-tool label { flex: 1; }
.stat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stat-head b { margin-right: auto; font: 700 15px var(--sans); }
.stat-row { display: grid; grid-template-columns: 44px 30px 34px 30px 1fr; align-items: center; gap: 4px; padding: 2px 0; }
#panel-body .stat-row { grid-template-columns: 44px 34px 30px 1fr; }
.stat-row b { font-weight: 700; }
.stat-row em { font-style: normal; font-size: 12px; color: var(--mute); padding-left: 6px; }
.stat-val { text-align: center; font-weight: 700; color: var(--gold); }
.stat-btn { width: 30px; height: 26px; padding: 0; background: #2a2f3e; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }
.stat-btn:hover:not(:disabled) { border-color: var(--gold); }
.stat-btn:disabled { opacity: .35; cursor: default; }
.stat-sum { margin-top: 6px; padding: 6px 8px; background: #141824; border-radius: 6px; font-size: 12.5px; color: var(--ink); }
.name-row { margin-top: 8px; }
#sex-box { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
#sex-box .btn { min-width: 84px; }
#sex-box .btn.on { background: #7a5a22; border-color: var(--gold); color: #fff; }
#panel-body .stats { margin: 8px 0 10px; }
#classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 8px; }
.cls { display: flex; flex-direction: column; justify-content: flex-start; padding: 8px 6px; background: #1b1f2c; border: 2px solid #333a4a; border-radius: 8px; text-align: center; }
.cls.sel { border-color: var(--gold); background: #292a2c; }
.cls img { display: block; width: 76px; height: 76px; margin: -2px auto 0; }
.cls b { display: block; font: 700 17px var(--serif); }
.cls em { display: block; font-style: normal; font-size: 12px; color: var(--gold); }
.cls span { display: block; font-size: 12px; color: var(--mute); line-height: 1.35; margin-top: 3px; }
.hint { color: var(--mute); font-size: 12px; }
.login-err { min-height: 21px; color: #ff8a7a; font-size: 13px; }
#login-btn { width: 100%; padding: 10px; background: #7a5a22; border: 1px solid var(--gold); border-radius: 8px; font-weight: 700; color: #fff; }
#login-btn:disabled { opacity: .6; cursor: default; }

#lost { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 12, .8); text-align: center; }
#lost h2 { font: 700 22px var(--serif); color: var(--gold); margin-bottom: 6px; }
#lost p { color: var(--mute); margin-bottom: 12px; }
#lost button { padding: 8px 18px; background: #7a5a22; border: 1px solid var(--gold); border-radius: 8px; color: #fff; }

@media (max-width: 900px) {
  #target { width: calc(100vw - 148px); max-width: 240px; }
  #side { width: 112px; }
  #mini { width: 112px; height: 112px; }
  #tracker, #boss-timer { font-size: 11px; }
  #bossbar { left: 12px; right: 136px; top: auto; bottom: calc(var(--bar-h) + 36px); width: auto; transform: none; }
  #classes { grid-template-columns: repeat(2, 1fr); }
  .bag-top { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (min-height: 601px) {
  #win-skill { right: 10px; top: 448px; }   /* 窄長視窗:技能放在道具欄下面,才不會蓋到角色視窗。畫面矮(手機橫拿)時放不下,照原本的位置 */
}
@media (max-width: 640px) {   /* 手機直拿:狀態欄收起來,留下血魔條、聊天和快捷鍵 */
  :root { --hk: 42px; }
  #bar { grid-template-columns: minmax(0, 1fr) 184px; }
  #st { display: none; }
  #vitals { gap: 4px; }
  #crest { display: none; }
  #vitals .bar b { font-size: 11px; }
}
/* 手機橫拿這種很矮的畫面:視窗可以往下蓋住底部介面,才看得到全部內容,關掉就回到原本的畫面。
   按「放到快捷鍵」時視窗先藏起來,讓出快捷鍵格子,放好再出現 */
@media (max-height: 500px) {
  .win { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
  #panel { top: 50%; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  #win-bag { right: 226px; }   /* 放在快捷鍵那一欄左邊,右下的快捷鍵和選單按鈕一直點得到 */
  #win-skill { right: auto; left: 10px; }
  body.trading #win-bag { right: 10px; }   /* 交易時:交易視窗靠左、道具欄靠右,兩個不重疊 */
  #win-trade { width: min(470px, calc(100vw - 360px)); }
}

.tabs { display: flex; gap: 4px; margin: 8px 0; border-bottom: 1px solid var(--line); }
.tabs button { padding: 5px 12px; background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; color: var(--mute); }
.tabs button.on { background: #2a2f3e; border-color: var(--line); color: var(--gold); }
.gear-grid { display: grid; grid-template-columns: repeat(3, 48px); justify-content: start; }
.grow { flex: 1; min-width: 0; }
.recipe { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(74, 66, 51, .5); }
.recipe b { display: block; font-size: 13px; }
.needs { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: #a8c8a0; }
.needs .lack { color: #e08a7a; }
.aff { color: #8fd0a0; font-size: 13px; margin-bottom: 2px !important; }
.set-line { font-size: 12px; margin-bottom: 4px !important; }
.trade-row .cell { flex: none; width: 32px; height: 32px; }
.wh-gold { margin-bottom: 8px; }
#wh-gold { width: 110px; }
/* 2026-11-04 時裝欄:角色視窗人形下面一排 4 格和顯示開關,道具欄左邊已裝備欄最下面一份 */
#fashion-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 6px; background: rgba(255, 140, 207, .07); border: 1px solid #6a3c58; }
#fashion-row > b { flex: none; color: #ff8ccf; font-size: 13px; }
.fashion-cells { display: flex; gap: 4px; }
.fashion-cells .cell { background: rgba(10, 8, 6, .62); }
.fashion-cells .cell:empty::after, #bag-worn .cell:empty::after { content: attr(data-label); position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #6e6456; }
#fashion-hide { margin-left: auto; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
#fashion-hide.on { border-color: #ff8ccf; color: #ffd3ec; }
#bag-worn .worn-head { grid-column: 1 / -1; margin: 4px 0 0; font-size: 11px; color: #ff8ccf; text-align: center; }
