/* 經典天堂倖存者：天堂風介面 */
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; color: #e9dcb8; }
canvas#cv { display: block; width: 100vw; height: 100vh; }
.hide { display: none !important; }
button { font-family: inherit; }

/* 遊戲中按鈕 */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.hbtn { pointer-events: auto; position: absolute; border: 2px solid #8c6d32; background: rgba(20, 15, 8, .8); color: #f4d27a; border-radius: 4px; cursor: pointer; }
#btnPause { right: 10px; top: 10px; width: 40px; height: 40px; font-size: 13px; font-weight: 900; }
#btnTele { right: 12px; bottom: 72px; width: 58px; height: 58px; padding: 0; }
#btnTele img { width: 34px; height: 34px; image-rendering: pixelated; margin-top: 4px; }
#btnTele b { position: absolute; right: 4px; bottom: 1px; font-size: 14px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
#btnTele.off { opacity: .35; }

/* 畫面 */
.scr { position: fixed; inset: 0; display: none; align-items: center; justify-content: flex-start; flex-direction: column; z-index: 5; padding: 12px; box-sizing: border-box;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
/* 內容比螢幕高時從頂端排、可以捲（垂直置中會把上半截推到捲不到的地方） */
.scr > :not(.bg) { margin-top: auto; margin-bottom: auto; flex-shrink: 0; }
.scr.on { display: flex; }
.scr.dim { background: rgba(4, 3, 2, .66); }
.bg { position: absolute; inset: 0; background: #000 center/cover no-repeat; z-index: -1; }
.bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.75)); }
.title-bg { background-image: url(../assets/ui/login.webp?v=2); }
.sel-bg { background-image: url(../assets/ui/charsel.webp?v=2); filter: brightness(.55); }
.load-bg { background-image: url(../assets/ui/loading.webp?v=2); }

.title-box { text-align: center; margin-top: 18vh; }
.logo { font-size: 56px; font-weight: 900; letter-spacing: 8px; color: #f6d986;
  text-shadow: 0 3px 0 #3a2400, 0 0 18px rgba(255, 180, 60, .55), 0 0 2px #000; }
.sub { font-size: 16px; color: #d8c79c; letter-spacing: 4px; margin: 6px 0 26px; text-shadow: 0 1px 3px #000; }
.how { margin-top: 18px; font-size: 14px; line-height: 1.9; color: #e2d6b4; background: rgba(0, 0, 0, .55); border: 1px solid #6a5630; padding: 10px 18px; border-radius: 4px; display: inline-block; }
.how b { color: #f4d27a; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.row.small { margin-top: 10px; }

.btn { font-size: 17px; font-weight: 700; color: #f6e6b6; background: linear-gradient(#6a5428, #3a2c12); border: 2px solid #c9a24e; border-radius: 4px; padding: 8px 26px; cursor: pointer; text-shadow: 0 1px 0 #000; box-shadow: inset 0 1px 0 rgba(255, 240, 190, .25), 0 2px 8px rgba(0, 0, 0, .6); }
.btn:hover { filter: brightness(1.2); }
.btn:disabled { filter: grayscale(1) brightness(.6); cursor: default; }
.btn.big { font-size: 21px; padding: 10px 40px; }
.btn.sm { font-size: 14px; padding: 5px 16px; border-color: #7d6a44; }

.frame { background: linear-gradient(#2a2216, #120d07); border: 2px solid #8c6d32; outline: 1px solid #000; box-shadow: 0 0 0 4px rgba(140, 109, 50, .25), 0 10px 40px rgba(0, 0, 0, .8), inset 0 0 30px rgba(0, 0, 0, .6);
  padding: 16px 22px; border-radius: 4px; max-width: 94vw; box-sizing: border-box; }
.frame.wide { width: 1000px; }
.ttl { font-size: 24px; font-weight: 900; color: #f4d27a; text-align: center; margin-bottom: 12px; text-shadow: 0 2px 0 #000; letter-spacing: 3px; }
.note { text-align: center; color: #bfae84; font-size: 14px; margin-bottom: 12px; }

/* 選職業 */
.class-list { display: flex; gap: 10px; justify-content: center; }
.cls { flex: 1; max-width: 180px; background: rgba(0, 0, 0, .45); border: 2px solid #4e3e1e; border-radius: 4px; padding: 6px; cursor: pointer; text-align: center; transition: border-color .1s; }
.cls:hover { border-color: #a8873e; }
.cls.on { border-color: #f4d27a; background: rgba(120, 90, 30, .25); }
.cls canvas { width: 100%; aspect-ratio: 160 / 270; display: block; }
.cls .nm { font-size: 18px; font-weight: 900; color: #f6e6b6; margin-top: 2px; }
.gender { display: flex; gap: 4px; justify-content: center; margin-top: 4px; }
.gender span { font-size: 13px; padding: 1px 10px; border: 1px solid #5a4a2a; border-radius: 3px; cursor: pointer; color: #bfae84; }
.gender span.on { border-color: #f4d27a; color: #f4d27a; background: rgba(120, 90, 30, .4); }
.class-info { margin-top: 12px; min-height: 64px; text-align: center; font-size: 15px; line-height: 1.7; color: #e2d6b4; }
.class-info b { color: #f4d27a; }
.class-info .stats { color: #bfae84; font-size: 13px; }

/* 章節 */
.chapter-list { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.chap { width: 300px; background: rgba(0, 0, 0, .45); border: 2px solid #4e3e1e; border-radius: 4px; cursor: pointer; overflow: hidden; position: relative; }
.chap:hover { border-color: #f4d27a; }
.chap.lock { cursor: default; filter: grayscale(1) brightness(.5); }
.chap .pic { height: 140px; background: #000 center/cover no-repeat; }
.chap .bd { padding: 8px 12px 12px; }
.chap .nm { font-size: 20px; font-weight: 900; color: #f6e6b6; }
.chap .rc { font-size: 12px; color: #9fd0ff; margin: 2px 0 6px; }
.chap .ds { font-size: 14px; color: #d4c7a2; line-height: 1.6; min-height: 44px; }
.chap .best { font-size: 13px; color: #ffd76a; margin-top: 6px; }
.chap .lk { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 900; color: #fff; text-shadow: 0 0 6px #000; }

/* 精靈屬性 */
.elem-list { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.elem { width: 150px; background: rgba(0, 0, 0, .45); border: 2px solid #4e3e1e; border-radius: 4px; cursor: pointer; text-align: center; padding: 8px; }
.elem:hover { border-color: #f4d27a; }
.elem canvas { width: 120px; height: 120px; }
.elem .nm { font-size: 22px; font-weight: 900; }
.elem .ds { font-size: 13px; color: #d4c7a2; }

/* 讀取 */
.load-box { position: absolute; bottom: 12vh; left: 50%; transform: translateX(-50%); width: min(520px, 86vw); text-align: center; }
#loadTxt { font-size: 15px; color: #f0e2bc; text-shadow: 0 1px 3px #000; margin-bottom: 8px; }
.lbar { height: 12px; border: 1px solid #8c6d32; background: rgba(0, 0, 0, .7); }
.lbar i { display: block; height: 100%; width: 0; background: linear-gradient(#ffe58a, #b07a12); }

/* 升級卡 */
.lvbox { text-align: center; }
.cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.card { width: 216px; min-height: 248px; box-sizing: border-box; background: linear-gradient(#2a2216, #120d07); border: 2px solid #7d6332; border-radius: 4px; padding: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; transition: transform .1s, border-color .1s; box-shadow: inset 0 0 18px rgba(0, 0, 0, .6), 0 6px 20px rgba(0, 0, 0, .6); }
.card:hover { transform: translateY(-3px); border-color: #f4d27a; }
.card.book { border-color: #b07dff; box-shadow: inset 0 0 18px rgba(0, 0, 0, .6), 0 0 18px rgba(170, 110, 255, .45); }
.card .ic { width: 64px; height: 64px; border: 1px solid #8c6d32; background: #000; display: flex; align-items: center; justify-content: center; }
.card .ic canvas, .card .ic img { width: 64px; height: 64px; image-rendering: auto; }
.card .ic img.pix { image-rendering: pixelated; }
.card .ic .stat { font-size: 30px; font-weight: 900; color: #f4d27a; }
.card .nm { font-size: 20px; font-weight: 900; margin-top: 8px; color: #f6e6b6; }
.card .lv { font-size: 13px; margin: 3px 0 8px; color: #8fd0ff; }
.card .lv.new { color: #7dff9a; }
.card .lv.evo { color: #d4a8ff; }
.card .ds { font-size: 14px; line-height: 1.6; color: #d4c7a2; flex: 1; }
.card .ds b { color: #ffe28a; }
.card .key { font-size: 12px; color: #7d6e4e; margin-top: 6px; }

.pause-info, .res-info { font-size: 15px; line-height: 1.9; min-width: 280px; text-align: center; }
.res-info b { color: #f4d27a; }
.res-info .dmg { margin: 8px auto 0; font-size: 13px; text-align: left; display: table; }
.res-info .dmg div { display: flex; gap: 10px; justify-content: space-between; min-width: 240px; }
.res-info .dmg i { font-style: normal; color: #bfae84; }

@media (max-width: 760px) {
  .logo { font-size: 36px; letter-spacing: 4px; }
  .title-box { margin-top: 10vh; }
  .how { font-size: 12px; }
  .frame { padding: 10px 10px; }
  .class-list { gap: 4px; }
  .cls { flex: 1 1 0; min-width: 0; padding: 3px; }
  .cls .nm { font-size: 14px; }
  .gender span { padding: 1px 5px; font-size: 12px; }
  .cards { flex-direction: column; gap: 8px; }
  .card { width: 92vw; min-height: 0; flex-direction: row; text-align: left; align-items: center; padding: 8px; gap: 10px; }
  .card .ic, .card .ic canvas, .card .ic img { width: 52px; height: 52px; flex: none; }
  .card .txt { flex: 1; }
  .card .nm { margin-top: 0; font-size: 17px; }
  .card .lv { margin: 1px 0 3px; }
  .card .key { display: none; }
  .chap { width: 92vw; display: flex; }
  .chap .pic { width: 120px; height: auto; flex: none; }
  .ttl { font-size: 20px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .title-box { margin-top: 2vh; }
  .logo { font-size: 34px; }
  .sub { margin-bottom: 10px; }
  .cards { flex-direction: row; flex-wrap: nowrap; }
  .card { width: 31vw; min-height: 0; padding: 6px 8px; flex-direction: row; align-items: flex-start; gap: 8px; text-align: left; }
  .card .ic, .card .ic canvas, .card .ic img { width: 44px; height: 44px; flex: none; }
  .card .nm { font-size: 15px; margin-top: 0; white-space: nowrap; }
  .card .lv { font-size: 11px; white-space: nowrap; }
  .card .ds { font-size: 11px; white-space: nowrap; }
  .card .key { display: none; }
  .cls canvas { max-height: 30vh; width: auto; margin: 0 auto; }
  .frame { padding: 8px 12px; }
  .ttl { font-size: 18px; margin-bottom: 6px; }
  .class-info { margin-top: 4px; min-height: 0; font-size: 13px; line-height: 1.5; }
  .row { margin-top: 6px; }
  .chap .pic { height: 70px; }
  .chap .ds { min-height: 0; font-size: 12px; }
}
.scr { overflow-x: hidden; }
.card .ds, .card .lv, .card .nm { white-space: nowrap; overflow: hidden; max-width: 100%; }
.card .txt { min-width: 0; max-width: 100%; width: 100%; }
@media (max-width: 760px) { .card .txt { width: auto; flex: 1; } }
@media (max-height: 520px) and (orientation: landscape) { .card .txt { width: auto; flex: 1; } }

/* ===== 帳號、角色欄、大廳、血盟、排行榜 ===== */
.frame.narrow { width: 380px; }
.fld { display: block; margin: 8px 0; font-size: 15px; color: #d8c79c; }
.fld input, .inp { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; font-size: 16px; padding: 7px 10px; color: #f6e6b6;
  background: #0d0a06; border: 1px solid #6a5630; border-radius: 3px; outline: none; }
.fld input:focus, .inp:focus { border-color: #f4d27a; }
.inp { width: 260px; max-width: 80vw; display: inline-block; }
.msg { min-height: 20px; text-align: center; font-size: 14px; color: #ff9a7a; margin-top: 6px; }
.msg.okk { color: #9effc8; }

.char-list { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.slot { width: 200px; background: rgba(0, 0, 0, .45); border: 2px solid #4e3e1e; border-radius: 4px; padding: 8px; cursor: pointer; text-align: center; position: relative; }
.slot:hover { border-color: #f4d27a; }
.slot img.still { width: 120px; height: 202px; object-fit: contain; display: block; margin: 0 auto; }
.slot .nm { font-size: 18px; font-weight: 900; color: #f6e6b6; white-space: nowrap; overflow: hidden; }
.slot .sub2 { font-size: 13px; color: #bfae84; white-space: nowrap; }
.slot .clan { font-size: 13px; color: #9fd0ff; white-space: nowrap; display: flex; gap: 4px; justify-content: center; align-items: center; min-height: 18px; }
.slot.empty { display: flex; align-items: center; justify-content: center; min-height: 270px; color: #8c7d5a; font-size: 17px; }
.slot.empty b { font-size: 40px; display: block; color: #a8873e; }
.slot .del { position: absolute; right: 4px; top: 4px; font-size: 12px; padding: 1px 6px; border: 1px solid #6a3a2a; color: #e08a7a; border-radius: 3px; background: rgba(0,0,0,.5); }
canvas.emb { image-rendering: pixelated; vertical-align: middle; border: 1px solid rgba(0,0,0,.6); }

.lobby { width: 560px; }
.lobby-head { display: flex; gap: 14px; align-items: center; }
.lobby-head img.face { width: 84px; height: 84px; border: 1px solid #8c6d32; }
.lobby-head .nm { font-size: 22px; font-weight: 900; color: #f6e6b6; }
.lobby-head .inf { font-size: 14px; line-height: 1.7; color: #d4c7a2; }
.lobby-head .inf b { color: #f4d27a; }
.lobby-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.clan-frame { max-height: 92vh; display: flex; flex-direction: column; }
.clan-body { overflow-y: auto; flex: 1; min-height: 120px; }
.clan-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.clan-head .nm { font-size: 24px; font-weight: 900; color: #f6e6b6; }
.clan-head .inf { font-size: 14px; color: #d4c7a2; line-height: 1.7; }
.notice { background: rgba(0,0,0,.4); border: 1px solid #4e3e1e; padding: 8px 10px; font-size: 14px; color: #e2d6b4; white-space: pre-wrap; min-height: 22px; margin-bottom: 8px; }
table.tb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tb th { color: #f4d27a; font-weight: 700; border-bottom: 1px solid #6a5630; padding: 4px 6px; text-align: left; white-space: nowrap; }
table.tb td { border-bottom: 1px solid rgba(106, 86, 48, .35); padding: 5px 6px; white-space: nowrap; }
table.tb tr.me td { background: rgba(140, 109, 50, .18); }
.tb .acts button { margin-left: 4px; }
.mini { font: inherit; font-size: 12px; padding: 2px 8px; color: #f6e6b6; background: linear-gradient(#5a4622, #2e2410); border: 1px solid #a8873e; border-radius: 3px; cursor: pointer; }
.mini.red { border-color: #a8503e; color: #ffb4a4; }
.sect { font-size: 16px; font-weight: 900; color: #f4d27a; margin: 12px 0 6px; }
.emb-edit { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.emb-edit canvas.grid { width: 256px; height: 192px; image-rendering: pixelated; cursor: crosshair; border: 1px solid #8c6d32; background: #000; touch-action: none; }
.pal { display: grid; grid-template-columns: repeat(4, 26px); gap: 4px; }
.pal i { width: 26px; height: 26px; border: 2px solid #333; cursor: pointer; display: block; }
.pal i.on { border-color: #f4d27a; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.tabs button.on { border-color: #f4d27a; filter: brightness(1.25); }
.rank-body { max-height: 60vh; overflow-y: auto; }
.res-net { text-align: center; font-size: 14px; margin-top: 6px; color: #9effc8; min-height: 18px; }
.res-net.err { color: #ff9a7a; }
.dlg { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.dlg-txt { font-size: 16px; line-height: 1.8; text-align: center; color: #f0e2bc; margin-bottom: 6px; }
@media (max-width: 760px) {
  .slot { width: 44vw; padding: 6px; }
  .slot img.still { width: 80px; height: 135px; }
  .slot.empty { min-height: 180px; }
  .lobby { width: 94vw; }
  table.tb { font-size: 12px; }
  .emb-edit canvas.grid { width: 192px; height: 144px; }
}
@media (max-width: 440px) {
  .rank-body table.tb th:nth-child(3), .rank-body table.tb td:nth-child(3),
  .rank-body table.tb th:nth-child(7), .rank-body table.tb td:nth-child(7) { display: none; }
}
