/* pk/assets/pk.css — HUD Võ Đài Ngoại Truyện.
   Màn hình chơi game toàn khung: texture lấy từ client (pk/assets/ui, xuất bằng
   LinhTinh/export_pk_ui.py), bảng màu xanh ngọc của UI gốc. */
@font-face { font-family: "NL Title"; src: url("/assets/fonts/BEAUFORTFORLOL-BOLD.TTF") format("truetype"); font-display: swap; }
@font-face { font-family: "NL Body"; src: url("/assets/fonts/Signika-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: dark;
  --ink: #f4efdc;
  --ink-2: #b8c8bc;
  --ink-3: #789888;
  --gold: #d0a850;
  --gold-2: #f8e898;
  --jade: #58c098;
  --jade-line: rgba(120, 152, 136, .55);
  --panel: rgba(8, 40, 32, .9);
  --panel-2: rgba(40, 56, 56, .92);
  --win: #7fe08f;
  --lose: #ff8f7f;
  --draw: #9fc5e8;
  --title: "NL Title", "NL Body", Georgia, serif;
  --body: "NL Body", "Segoe UI", system-ui, sans-serif;
  --gutter: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: #04120f;
  color: var(--ink);
  font: 400 15px/1.35 var(--body);
  -webkit-text-size-adjust: 100%;
}
h1, h2, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; z-index: 50; background: #000; padding: 8px 12px; }
.skip:focus { left: 8px; top: 8px; }

/* Thế giới phía sau HUD: bản đồ có đấu trường bát giác ở giữa. */
.world {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(75% 70% at 50% 48%, rgba(10, 22, 14, 0), rgba(6, 16, 10, .62) 100%),
    linear-gradient(180deg, rgba(6, 16, 10, .42), rgba(6, 16, 10, 0) 18%, rgba(6, 16, 10, 0) 78%, rgba(6, 16, 10, .55)),
    url("/pk/assets/ui/redland.webp") center 40% / cover no-repeat #33502f;
}

/* Khung HUD: máy tính vừa khít một màn hình, không cuộn trang. */
.hud {
  height: 100dvh; min-height: 620px;
  display: grid; gap: 10px; padding: 10px 14px;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(290px, 350px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top   top   top"
    "chat  stage right"
    "chat  dock  right";
}
.top { grid-area: top; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; }
.stage { grid-area: stage; }
.right { grid-area: right; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat { grid-area: chat; align-self: end; height: min(320px, 44vh); }
.dock { grid-area: dock; }
.tabs { display: none; }

/* --- Khung nhân vật góc trái --- */
.unit { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  position: relative; flex: none; width: 92px; height: 92px; padding: 0; border: 0;
  background: none;
  transition: transform .12s ease, filter .12s ease;
}
.avatar:hover { filter: brightness(1.15); transform: scale(1.03); }
.avatar::before { content: ""; position: absolute; inset: 0; background: url("/pk/assets/ui/f12.webp") center / 100% 100% no-repeat; }
.avatar::after { content: ""; position: absolute; inset: 0; background: url("/pk/assets/ui/f13.webp") center / 100% 100% no-repeat; pointer-events: none; }
.av-ring { position: absolute; inset: -1px; background: url("/pk/assets/ui/f12_1.webp") center / 100% 100% no-repeat; pointer-events: none; }
.avatar img {
  position: absolute; left: 7%; top: 7%; width: 86%; height: 86%;
  border-radius: 50%; object-fit: cover;
}
.avatar .lv { z-index: 1; }
.avatar .lv {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  min-width: 44px; padding: 1px 8px; text-align: center;
  font: 700 12px/1.45 var(--title); color: #203818;
  background: url("/pk/assets/ui/f4_1.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 1px 2px #000a);
}
.unit-body { min-width: 0; flex: 1; text-shadow: 0 1px 3px #000; }
.unit-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.unit-name strong { font: 700 19px/1.2 var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { flex: none; padding: 0 7px; border-radius: 9px; font-size: 12px; color: var(--gold-2); background: rgba(0, 0, 0, .55); border: 1px solid rgba(245, 207, 114, .35); text-shadow: none; }
.flag { flex: none; width: 20px; height: 24px; object-fit: contain; }
.segbar { margin: 5px 0 6px; max-width: 220px; height: 14px; padding: 2px; background: url("/pk/assets/ui/ui_new_world_time_bg1.webp") center / 100% 100% no-repeat, rgba(0, 0, 0, .55); }
.segbar b { display: block; height: 100%; background: url("/pk/assets/ui/ui_new_world_time_1.webp") left center / auto 100% repeat-x; }
.res { display: flex; gap: 6px; flex-wrap: wrap; }
.res div { display: flex; align-items: baseline; gap: 4px; padding: 1px 8px; border-radius: 10px; background: rgba(0, 0, 0, .55); }
.res dt { font-size: 12px; color: var(--ink-2); }
.res dd { font: 700 15px/1.25 var(--title); color: var(--gold-2); }

/* --- Bảng tên giữa --- */
.plaque {
  min-width: 340px; padding: 7px 44px 11px; text-align: center;
  background: url("/pk/assets/ui/plaque.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 3px 8px #000b);
}
.plaque h1 { font: 700 21px/1.15 var(--title); letter-spacing: .4px; background: linear-gradient(#fff4c7, #e8b64e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plaque p { font-size: 12px; color: var(--ink-2); }
.plaque b { color: var(--gold-2); font-weight: 400; }

/* --- Nút menu phải --- */
.menu { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.mbtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 64px; padding: 0; border: 0; background: none; text-decoration: none;
  font: 700 12px/1.1 var(--title); color: var(--gold-2); text-shadow: 0 0 3px #000, 0 1px 2px #000;
  transition: transform .1s ease, filter .1s ease;
}
.mbtn .ic { width: 50px; height: 50px; object-fit: contain; filter: drop-shadow(0 2px 3px #000a); }
.mbtn:hover { filter: brightness(1.25); transform: translateY(-1px); }

/* --- Panel kiểu cửa sổ game --- */
.panel {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  padding: 8px 10px 10px; border-radius: 8px;
  background: var(--panel);
  border: 14px solid transparent; border-image: url("/pk/assets/ui/a1038.webp") 16 fill / 14px stretch;
  padding: 0 0 2px; border-radius: 0;
  box-shadow: 0 6px 18px #0009;
}
.panel > h2 {
  flex: none; margin: -2px -4px 7px; padding: 3px 0 4px; text-align: center;
  font: 700 15px/1.2 var(--title); color: var(--gold-2);
  background: url("/pk/assets/ui/ui_new_world_passagebg1.webp") center / 100% 100% no-repeat;
}

/* --- Nhiệm vụ --- */
.goal { padding: 2px 4px 6px; font: 700 15px/1.3 var(--title); color: var(--gold); }
.goal::before { content: ""; display: inline-block; width: 13px; height: 13px; margin-right: 5px; vertical-align: -1px; background: url("/pk/assets/ui/ui_new_world_point.webp") center / contain no-repeat; }
.tracker li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 4px; font-size: 13.5px; color: var(--ink-2); }
.tracker b { font: 700 14px/1.3 var(--title); color: var(--ink); white-space: nowrap; }
.tracker .warn b { color: var(--lose); }

/* --- Đối thủ --- */
.foes { flex: 1; }
.srv-tabs { flex: none; display: flex; gap: 4px; margin-bottom: 6px; }
.srv-tabs button {
  flex: 1; min-width: 0; padding: 4px 2px; border-radius: 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(0, 0, 0, .4); border: 1px solid var(--jade-line); color: var(--ink-2);
}
.srv-tabs button[aria-pressed="true"] { border: 8px solid transparent; border-image: url("/pk/assets/ui/btn_1_1.webp") 16 fill / 8px stretch; padding: 0 0; color: var(--gold-2); background: none; }
.search { flex: none; display: block; margin-bottom: 6px; }
.search input { width: 100%; padding: 6px 10px; border-radius: 6px; background: rgba(0, 0, 0, .5); border: 1px solid var(--jade-line); }
.search input::placeholder { color: var(--ink-3); }
.foe-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; scrollbar-color: #2c7f6b transparent; scrollbar-width: thin; }
.foe-row {
  flex: none; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 4px 8px 4px 5px; text-align: left; border: 1px solid rgba(120, 152, 136, .4); border-radius: 2px;
  background: rgba(40, 56, 56, .72);
  transition: filter .1s ease;
}
.foe-row:hover:not(:disabled) { filter: brightness(1.2); }
.foe-row[aria-pressed="true"] { border: 8px solid transparent; padding: 0 2px 0 0; border-image: url("/pk/assets/ui/btn_1_0.webp") 16 fill / 8px stretch; background: none; }
.foe-row:disabled { filter: grayscale(.7) brightness(.75); cursor: not-allowed; }
.foe-row[aria-pressed="true"] .fname { color: var(--gold-2); }
.foe-row[aria-pressed="true"] .fsub { color: #e4efe2; }
.foe-row .face { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: #06211d; box-shadow: 0 0 0 1px #0009; }
.fname img { flex: none; object-fit: contain; }
.fname { display: flex; align-items: center; gap: 4px; font-weight: 400; font-size: 14.5px; text-shadow: 0 1px 2px #000; min-width: 0; }
.fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsub { display: block; font-size: 12px; color: var(--ink-2); text-shadow: 0 1px 2px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fpts { font: 700 15px/1 var(--title); color: var(--gold-2); text-shadow: 0 1px 2px #000; }
.empty { padding: 12px 4px; text-align: center; font-size: 13.5px; color: var(--ink-2); }
.empty a { color: var(--gold-2); }

/* --- Sân khấu --- */
.stage { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr); align-items: center; align-content: center; gap: 4px 6px; }
.side { min-width: 0; }
.nameplate { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 360px; margin: 0 auto 6px; padding: 3px 10px; min-width: 0; background: url("/pk/assets/ui/ui_f_62.webp") center / 100% 100% no-repeat; }
.banner { flex: none; width: 58px; height: 76px; margin: -6px 0 -8px; filter: drop-shadow(0 3px 5px #000b); }
.np-text { min-width: 0; text-align: left; }
.np-title { display: block; font: 700 17px/1.2 var(--title); color: var(--gold-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px #000; }
.side.foe .np-title { color: #ffb9a6; }
.np-sub { display: block; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; max-width: 330px; margin: 0 auto; filter: drop-shadow(0 8px 12px #000c); }
.cell {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; overflow: hidden; border-radius: 3px;
  background: rgba(8, 18, 12, .62); box-shadow: inset 0 0 0 1px rgba(232, 196, 112, .34);
}
.cell.filled { background: #0a2d27; box-shadow: 0 2px 5px #000a; cursor: pointer; }
.cell.filled::after { content: ""; position: absolute; inset: 0; background: url("/pk/assets/ui/frame-2.webp") center / 100% 100% no-repeat; pointer-events: none; }
.side.foe .cell.filled::after { background-image: url("/pk/assets/ui/frame-4.webp"); }
.cell[aria-pressed="true"]::after { background-image: url("/pk/assets/ui/frame-7.webp") !important; }
.cell > img { width: 100%; height: 100%; object-fit: cover; }
.cell .init { display: grid; place-items: center; width: 100%; height: 100%; font: 700 26px/1 var(--title); color: var(--gold-2); }
.cell .clv { position: absolute; left: 4px; top: 3px; z-index: 1; padding: 0 4px; border-radius: 3px; font: 700 11px/1.35 var(--title); color: var(--gold-2); background: rgba(0, 0, 0, .72); }
.cell .cnm { position: absolute; left: 3px; right: 3px; bottom: 8px; z-index: 1; font-size: 11.5px; line-height: 1.15; text-align: center; color: #fff; text-shadow: 0 0 3px #000, 0 1px 2px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .chp { position: absolute; left: 4px; right: 4px; bottom: 3px; z-index: 1; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .75); overflow: hidden; }
.cell .chp i { display: block; height: 100%; background: linear-gradient(#a7f3b5, #38b868); }
.side.foe .cell .chp i { background: linear-gradient(#ffb09e, #d7533f); }
.vs { text-align: center; padding-top: 28px; }
.vs img { margin: 0 auto; width: 60px; height: 60px; filter: drop-shadow(0 3px 5px #000b); }
.inspect { grid-column: 1 / -1; justify-self: center; max-width: 100%; margin-top: 6px; padding: 3px 14px; border-radius: 12px; font-size: 13.5px; color: var(--ink); background: rgba(0, 0, 0, .68); text-align: center; }

/* Hiệu ứng giao tranh trong lúc chờ kết quả */

/* --- Thanh dưới --- */
.dock { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-width: 0; }
.quickbar { display: flex; gap: 6px; min-width: 0; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.qslot {
  position: relative; flex: none; width: 64px; height: 64px; padding: 0; border: 0; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 10px solid transparent; border-image: url("/pk/assets/ui/ui_chat_bg7.webp") 12 fill / 6px stretch;
  border-width: 6px; white-space: nowrap;
  font-size: 11.5px; line-height: 1.15; color: var(--ink-2); text-shadow: 0 1px 2px #000;
  transition: transform .1s ease, filter .1s ease;
}
.qslot b { font: 700 19px/1.1 var(--title); color: var(--ink); }
.qslot:hover { filter: brightness(1.25); }
.qslot[aria-pressed="true"] { border-image-source: url("/pk/assets/ui/btn_1_1.webp"); border-image-slice: 16 fill; color: var(--gold-2); }
.qslot[aria-pressed="true"] b { color: var(--gold-2); }
.qslot.live b { font-size: 15px; }
.qslot span { font-size: 10.5px; }
.actions { flex: none; display: flex; align-items: flex-end; gap: 6px; }
.act {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; text-decoration: none; color: var(--ink);
  text-shadow: 0 1px 2px #000; transition: transform .1s ease, filter .1s ease;
}
.act:hover:not(:disabled):not([aria-disabled="true"]) { filter: brightness(1.18); transform: scale(1.05); }
.act:active:not(:disabled) { transform: scale(.96); }
.act.small { width: 66px; background: none; border-radius: 0; font: 700 11.5px/1.1 var(--title); color: var(--gold-2); text-shadow: 0 0 3px #000, 0 1px 2px #000; text-align: center; }
.act.small .ic { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 2px 3px #000a); }
.act[aria-disabled="true"], .act:disabled { filter: grayscale(.85) brightness(.72); cursor: not-allowed; }
.act.fight {
  position: relative; width: 118px; background: none; border-radius: 0; font: 700 14px/1 var(--title); color: #203818;
  animation: fight-pulse 1.5s ease-in-out infinite;
}
.act.fight .ic { width: 108px; height: 108px; object-fit: contain; }
.act.fight span { margin-top: -14px; z-index: 1; min-width: 104px; padding: 7px 8px 8px; text-shadow: none; background: url("/pk/assets/ui/f4_1.webp") center / 100% 100% no-repeat; }
.act.fight:hover:not(:disabled) span { background-image: url("/pk/assets/ui/f4_2.webp"); }
.act.fight:disabled { animation: none; }
@keyframes fight-pulse { 50% { filter: brightness(1.14) drop-shadow(0 0 14px rgba(248, 200, 64, .75)); } }

/* --- Chat --- */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding: 2px; font-size: 13.5px; scrollbar-color: #2c7f6b transparent; scrollbar-width: thin; }
.chat-log p { word-break: break-word; line-height: 1.3; }
.chat-log .srv { color: var(--jade); }
.chat-log .who { color: var(--gold); }
.chat-log time { color: var(--ink-3); font-size: 11.5px; margin-left: 4px; }
.chat-log .sys { color: var(--ink-3); font-style: italic; }
.chat-form { flex: none; display: flex; gap: 5px; margin-top: 6px; }
.chat-form input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 6px; background: rgba(0, 0, 0, .55); border: 1px solid var(--jade-line); }
.chat-form input::placeholder { color: var(--ink-3); }
.chat-form button { flex: none; width: 54px; border: 8px solid transparent; border-image: url("/pk/assets/ui/btn_1_0.webp") 16 fill / 8px stretch; background: none; padding: 0; font: 700 13px/1 var(--title); color: var(--gold-2); }
.chat-form button:hover:not(:disabled) { border-image-source: url("/pk/assets/ui/btn_1_1.webp"); }
.chat-form :disabled { opacity: .55; cursor: not-allowed; }

/* --- Cửa sổ --- */
.win { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.win-scrim { position: absolute; inset: 0; background: rgba(0, 8, 6, .72); }
.win-box {
  position: relative; width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 4px 6px 6px; background: rgba(8, 40, 32, .98);
  border: 16px solid transparent; border-image: url("/pk/assets/ui/ui_new_world_prompt_bg.webp") 24 fill / 16px stretch;
  box-shadow: 0 18px 50px #000;
}
.win-box > h2 { padding: 0 34px 8px; text-align: center; font: 700 20px/1.2 var(--title); color: var(--gold-2); border-bottom: 1px solid var(--jade-line); margin-bottom: 10px; }
.win-x { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--jade-line); background: rgba(0, 0, 0, .5); font-size: 20px; line-height: 1; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { padding: 4px 6px; font-weight: 400; font-size: 12.5px; color: var(--ink-2); text-align: left; border-bottom: 1px solid var(--jade-line); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid rgba(113, 214, 186, .12); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.me td { background: rgba(245, 207, 114, .13); }
.tbl .medal { width: 30px; height: 30px; object-fit: contain; }
.tbl a { color: var(--gold-2); }
.res-win { color: var(--win); } .res-lose { color: var(--lose); } .res-draw { color: var(--draw); }
.rules-list { display: grid; gap: 8px; font-size: 14.5px; }
.rules-list li { padding-left: 14px; position: relative; }
.rules-list li::before { content: "◆"; position: absolute; left: 0; color: var(--gold); font-size: 9px; top: 5px; }
.chars { display: grid; gap: 6px; }
.char-opt { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 6px 10px 6px 6px; text-align: left; border-radius: 6px; background: rgba(0, 0, 0, .34); border: 1px solid var(--jade-line); }
.char-opt:hover { background: rgba(95, 211, 180, .16); }
.char-opt[aria-pressed="true"] { border-color: var(--gold); background: rgba(245, 207, 114, .14); }
.char-opt img { width: 50px; height: 50px; border-radius: 6px; object-fit: cover; background: #06211d; }
.char-opt strong { display: block; font: 700 16px/1.2 var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-opt small { display: block; font-size: 12.5px; color: var(--ink-2); }
.char-opt .turns { text-align: right; font: 700 15px/1.2 var(--title); color: var(--gold-2); }
.char-opt .turns small { font: 400 11.5px/1.2 var(--body); }
.char-opt .turns.out { color: var(--lose); }

/* Kết quả trận */
.result { margin: -4px -6px 0; padding: 18px 16px 12px; text-align: center; background: linear-gradient(180deg, rgba(5, 34, 30, .15), #05221e), url("/pk/assets/ui/scene-fire.webp") center / cover no-repeat; }
.result.r-lose { background: linear-gradient(180deg, rgba(5, 34, 30, .3), #05221e), url("/pk/assets/ui/scene-cavalry.webp") center / cover no-repeat; }
.result img { margin: 0 auto; max-width: 62%; height: auto; }
.result .word-draw { font: 700 58px/1.15 var(--title); color: var(--draw); text-shadow: 0 3px 6px #000; }
.result .delta { margin-top: 2px; font: 700 26px/1.2 var(--title); text-shadow: 0 2px 4px #000; }
.result .vsline { margin-top: 2px; font-size: 14.5px; text-shadow: 0 1px 3px #000; }
.statgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0; }
.statgrid div { padding: 5px 10px; border-radius: 6px; background: rgba(0, 0, 0, .34); display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.statgrid b { font: 700 15px/1.3 var(--title); color: var(--ink); white-space: nowrap; }
.win-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.gbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 150px; min-height: 46px; padding: 0 10px; border: 12px solid transparent; border-image: url("/pk/assets/ui/btn_1_0.webp") 18 fill / 12px stretch; font: 700 15px/1.2 var(--title); color: var(--gold-2); text-decoration: none; background: none; text-shadow: 0 1px 2px #000; }
.gbtn:hover { border-image-source: url("/pk/assets/ui/btn_1_1.webp"); }
.gbtn.alt { color: var(--ink); filter: saturate(.55) brightness(.85); }
.note { margin-top: 8px; text-align: center; font-size: 12.5px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; top: 110px; z-index: 30; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); padding: 7px 16px; border-radius: 8px; background: rgba(0, 0, 0, .9); border: 1px solid var(--gold); text-align: center; font-size: 14px; }
.toast.err { border-color: var(--lose); color: #ffd7cf; }

/* --- Màn hình thấp trên desktop --- */
@media (max-height: 760px) and (min-width: 1101px) {
  .hud { min-height: 560px; gap: 6px; padding: 6px 12px; }
  .board { max-width: 250px; }
  .act.fight { width: 100px; }
  .act.fight .ic { width: 82px; height: 82px; }
  .chat { height: 38vh; }
}

/* --- Điện thoại/máy bảng: cuộn dọc, dock dính đáy, các khung thành tab --- */
@media (max-width: 1100px) {
  .hud {
    height: auto; min-height: 100dvh; padding: 8px var(--gutter) 150px; gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "top" "stage" "tabs" "right" "chat";
  }
  .top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "unit menu" "plaque plaque"; }
  .unit { grid-area: unit; }
  .menu { grid-area: menu; flex-wrap: nowrap; }
  .plaque { grid-area: plaque; justify-self: center; min-width: 0; width: min(100%, 380px); }
  .tabs { grid-area: tabs; display: flex; gap: 4px; }
  .tabs button { flex: 1; position: relative; min-height: 40px; border-radius: 6px 6px 0 0; border: 1px solid var(--jade-line); background: rgba(0, 0, 0, .62); color: var(--ink-2); }
  .tabs button[aria-selected="true"] { border: 8px solid transparent; border-image: url("/pk/assets/ui/btn_1_1.webp") 16 fill / 8px stretch; background: none; color: var(--gold-2); padding: 0; }
  .tabs .dot { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--lose); }
  .right { display: block; }
  .right .panel, .chat { display: none; }
  .right .panel.on, .chat.on { display: flex; }
  .chat { height: 420px; align-self: auto; }
  .foes { height: 460px; }
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    padding: 6px var(--gutter) calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(3, 16, 14, .97) 70%, transparent);
    flex-wrap: nowrap; align-items: flex-end;
  }
  .quickbar { flex: 1; }
  .qslot { width: 54px; height: 54px; }
  .act.small { width: 44px; font-size: 0; }
  .act.small .ic { width: 42px; height: 42px; }
  .act.small span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .act.fight { width: 88px; font-size: 12.5px; }
  .act.fight .ic { width: 72px; height: 72px; }
  .act.fight span { min-width: 84px; margin-top: -10px; padding: 6px 4px 7px; }
  #btn-replay { display: none; }
  .world { background-position: center top; }
}
@media (max-width: 560px) {
  .mbtn { width: 42px; padding: 5px 1px; font-size: 0; }
  .mbtn .ic { width: 40px; height: 40px; }
  .mbtn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .top { grid-template-columns: minmax(0, 1fr); grid-template-areas: "unit" "menu" "plaque"; gap: 6px; }
  .menu { gap: 4px; justify-content: space-between; }
  .mbtn { flex: 1; width: auto; }
  .avatar { width: 72px; height: 72px; }
  .unit-name strong { font-size: 16px; }
  .res { gap: 3px; }
  .res div { padding: 0 5px; gap: 3px; }
  .res dt { font-size: 11px; }
  .res dd { font-size: 13px; }
  .plaque { padding: 5px 30px 9px; }
  .plaque h1 { font-size: 17px; }
  .stage { grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr); gap: 3px; }
  .vs { padding-top: 24px; }
  .vs img { width: 30px; height: 30px; }
  .board { gap: 3px; }
  .cell .cnm { font-size: 9.5px; bottom: 6px; }
  .cell .clv { font-size: 9.5px; left: 2px; top: 2px; padding: 0 2px; }
  .cell .chp { height: 3px; bottom: 2px; }
  .nameplate { gap: 3px; padding: 2px 2px; }
  .banner { width: 28px; height: 37px; margin: 0; }
  .np-title { font-size: 13px; }
  .np-sub { font-size: 10px; white-space: normal; line-height: 1.15; }
  .inspect { font-size: 12.5px; }
  .toast { top: 70px; }
}

/* Điện thoại xoay ngang: bàn nhỏ lại để thấy đủ 3 hàng phía trên dock. */
@media (max-width: 1100px) and (max-height: 500px) {
  .board { max-width: 210px; }
  .banner { width: 36px; height: 47px; margin: 0; }
  .hud { padding-bottom: 120px; }
}

/* ---------- Đề xuất, nhãn so sức ---------- */
.srv-tabs button.rec { flex: 1.5; }
.ftag { flex: none; margin-left: 2px; padding: 0 5px; border-radius: 3px; font: 400 11px/1.5 var(--body); color: #06211d; }
.ftag.easy { background: #8fe0a0; }
.ftag.even { background: var(--gold-2); }
.ftag.hard { background: #ff9d84; }
.ftag.gap { background: #9fb7ad; }
.ftag.gap0 { background: #5d6f68; color: #e9efe9; }
.fpts small { display: block; margin-top: 3px; font: 400 11px/1 var(--body); color: var(--win); text-align: right; }
.foe-row { transition: transform .16s ease, filter .16s ease; }
.foe-row:hover:not(:disabled) { transform: translateX(-3px); }
.foe-row.enter { animation: row-in .32s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--i, 0) * 34ms); }
@keyframes row-in { from { opacity: 0; transform: translateX(18px); } }
.revenge { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; padding: 5px 6px 5px 10px; border: 1px solid rgba(255, 143, 127, .55); border-radius: 6px; background: linear-gradient(90deg, rgba(150, 40, 24, .55), rgba(60, 20, 14, .35)); font-size: 12.5px; animation: revenge-glow 1.8s ease-in-out infinite; }
.revenge span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revenge button { flex: none; padding: 3px 10px; border: 1px solid #ffb09e; border-radius: 4px; background: #a93a26; color: #fff4e6; font: 700 12.5px/1.2 var(--title); cursor: pointer; }
.revenge button:hover { background: #c94a33; }
@keyframes revenge-glow { 50% { box-shadow: 0 0 12px rgba(255, 110, 80, .55); } }
.linkbtn { margin-left: 8px; padding: 0; border: 0; background: none; color: var(--lose); font: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- Bậc danh hiệu ---------- */
.tag.tier { color: #06211d; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.segbar b { transition: width .6s ease; }

/* ---------- Thanh so lực chiến ---------- */
.powerbar { grid-column: 1 / -1; justify-self: center; display: flex; align-items: center; gap: 8px; width: min(100%, 460px); margin-top: 8px; font: 700 13px/1 var(--title); text-shadow: 0 1px 3px #000; animation: row-in-up .3s ease both; }
.powerbar span:first-child { color: #a7f3b5; }
.powerbar span:last-child { color: #ffb09e; }
.pb-track { flex: 1; display: flex; height: 10px; overflow: hidden; border-radius: 5px; background: #0009; box-shadow: 0 0 0 1px #000a; }
.pb-track i { display: block; height: 100%; transition: width .6s cubic-bezier(.2, .8, .3, 1); }
.pb-l { background: linear-gradient(#a7f3b5, #2f9e5b); }
.pb-r { background: linear-gradient(#ffb09e, #c6452f); box-shadow: inset 2px 0 0 #fff8; }
@keyframes row-in-up { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Thẻ tướng trên bàn ---------- */
.cell.filled { transition: transform .15s ease; }
.cell.filled:hover { transform: translateY(-3px) scale(1.03); z-index: 2; }
.board.dealing .cell.filled { animation: deal-l .42s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(var(--i, 0) * 45ms); }
.side.foe .board.dealing .cell.filled { animation-name: deal-r; }
@keyframes deal-l { from { opacity: 0; transform: translate(-46px, 16px) rotate(-10deg) scale(.8); } }
@keyframes deal-r { from { opacity: 0; transform: translate(46px, 16px) rotate(10deg) scale(.8); } }
.stage.ready .vs img { animation: vs-pulse 1.1s ease-in-out infinite; }
@keyframes vs-pulse { 50% { transform: scale(1.18); filter: drop-shadow(0 0 12px #ffb040); } }
.act.fight.cooling { filter: grayscale(.75) brightness(.8); }

/* ---------- Diễn trận trên bàn ---------- */
.cell .chp i { transition: width .35s ease-out; }
.cell.lunge-r { animation: lunge-r .3s ease-out; z-index: 3; }
.cell.lunge-l { animation: lunge-l .3s ease-out; z-index: 3; }
@keyframes lunge-r { 40% { transform: translateX(20px) scale(1.08); } }
@keyframes lunge-l { 40% { transform: translateX(-20px) scale(1.08); } }
.cell.hit { animation: hit-shake .3s linear; }
.cell.hit::before { content: ""; position: absolute; inset: 0; z-index: 1; background: rgba(255, 70, 40, .55); animation: hit-flash .3s ease-out both; pointer-events: none; }
@keyframes hit-shake { 20% { transform: translateX(-4px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }
@keyframes hit-flash { to { opacity: 0; } }
.cell.fallen > img, .cell.fallen .init { filter: grayscale(1) brightness(.45); transition: filter .35s ease; }
.cell.filled:has(.dmg) { overflow: visible; }
.dmg { position: absolute; left: 50%; top: 38%; z-index: 4; font: 700 19px/1 var(--title); color: #ffd7c9; white-space: nowrap; text-shadow: 0 0 6px #d7331a, 0 2px 3px #000; pointer-events: none; transform: translateX(-50%); animation: dmg-fly .85s ease-out both; }
@keyframes dmg-fly { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.6); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -38px) scale(1); } }

/* ---------- Màn giao tranh ---------- */
.duel { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 16px; overflow: hidden; background: radial-gradient(ellipse at center, rgba(120, 40, 8, .55), rgba(2, 10, 8, .94) 68%); animation: duel-in .22s ease-out both, duel-shake .3s linear .42s; }
.duel-side { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.duel-side img { width: min(26vw, 230px); height: min(26vw, 230px); object-fit: cover; border-radius: 10px; }
.duel-side.l img { box-shadow: 0 0 0 3px #58c098, 0 0 34px rgba(88, 192, 152, .75); }
.duel-side.r img { box-shadow: 0 0 0 3px #d7533f, 0 0 34px rgba(215, 83, 63, .75); }
.duel-side.l { animation: slam-l .42s cubic-bezier(.3, 0, .2, 1.25) both; }
.duel-side.r { animation: slam-r .42s cubic-bezier(.3, 0, .2, 1.25) both; }
.duel-side b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 24px/1.2 var(--title); color: var(--gold-2); text-shadow: 0 2px 5px #000; }
.duel-side span { font-size: 14px; color: var(--ink-2); }
.duel-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; animation: stamp .36s cubic-bezier(.2, 1.4, .4, 1) .34s both; }
.duel-mid img { width: 110px; height: 110px; filter: drop-shadow(0 0 18px #ff9d2e); animation: vs-pulse .7s ease-in-out .7s infinite; }
.duel-mid span { font: 700 34px/1 var(--title); color: #fff1c4; white-space: nowrap; text-shadow: 0 0 18px #ff9d2e, 0 3px 6px #000; }
@keyframes duel-in { from { opacity: 0; } }
@keyframes slam-l { from { opacity: 0; transform: translateX(-60vw) scale(1.25); } }
@keyframes slam-r { from { opacity: 0; transform: translateX(60vw) scale(1.25); } }
@keyframes stamp { from { opacity: 0; transform: scale(3); } }
@keyframes duel-shake { 20% { transform: translate(-7px, 3px); } 45% { transform: translate(6px, -4px); } 70% { transform: translate(-4px, -2px); } }

/* ---------- Màn kết quả ---------- */
.result { position: relative; overflow: hidden; isolation: isolate; }
.result.r-win::before { content: ""; position: absolute; left: 50%; top: 42%; z-index: -1; width: 620px; height: 620px; margin: -310px 0 0 -310px; background: repeating-conic-gradient(rgba(255, 214, 120, .24) 0 12deg, transparent 12deg 30deg); animation: rays 14s linear infinite; pointer-events: none; }
@keyframes rays { to { transform: rotate(360deg); } }
.result img, .result .word-draw { animation: stamp .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.result.r-lose { animation: lose-shake .4s linear .3s; }
.result.r-lose img { filter: saturate(.7); }
@keyframes lose-shake { 25% { transform: translateX(-5px); } 55% { transform: translateX(5px); } 80% { transform: translateX(-2px); } }
.result .delta { animation: row-in-up .3s ease .3s both; }
.streak, .tierup { display: inline-block; margin: 6px 4px 0; padding: 2px 12px; border-radius: 12px; font: 700 13.5px/1.4 var(--title); animation: stamp .36s cubic-bezier(.2, 1.4, .4, 1) .55s both; }
.streak { color: #2a1400; background: linear-gradient(90deg, #ffcf5e, #ff8f3e); }
.tierup { color: #06211d; background: linear-gradient(90deg, var(--gold-2), #fff8d0); box-shadow: 0 0 14px rgba(248, 232, 152, .8); }
.spark { position: absolute; left: 50%; top: 38%; z-index: 2; width: 6px; height: 6px; border-radius: 50%; background: #ffe39a; box-shadow: 0 0 8px #ffb040; pointer-events: none; animation: spark .85s cubic-bezier(.1, .7, .3, 1) both; }
@keyframes spark { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--x), var(--y)) scale(.3); } }
.statgrid b.rank-up { color: var(--win); }
.win-box { animation: win-in .24s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes win-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------- Bục Top 3 ---------- */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 6px; margin-bottom: 10px; }
.pod { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; animation: row-in-up .45s cubic-bezier(.2, .9, .3, 1.15) both; }
.pod-1 { animation-delay: .24s; }
.pod-2 { animation-delay: .12s; }
.pod-face { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px #b9c6cc; }
.pod-1 .pod-face { width: 82px; height: 82px; box-shadow: 0 0 0 3px var(--gold-2), 0 0 20px rgba(248, 232, 152, .6); }
.pod-3 .pod-face { box-shadow: 0 0 0 2px #c98a55; }
.pod-medal { width: 30px; height: 30px; margin-top: -15px; object-fit: contain; }
.pod-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 14.5px/1.3 var(--title); color: var(--gold-2); }
.pod-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--ink-2); }
.pod-step { width: 100%; margin-top: 5px; padding: 7px 2px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, rgba(88, 192, 152, .32), rgba(0, 0, 0, .25)); }
.pod-1 .pod-step { padding-top: 22px; background: linear-gradient(180deg, rgba(248, 232, 152, .38), rgba(0, 0, 0, .25)); }
.pod-step b { display: block; font: 700 17px/1.2 var(--title); }
.pod-step span { font-size: 11px; color: var(--ink-2); }
.pod.me .pod-step { box-shadow: inset 0 0 0 1px var(--gold-2); }
.tbl tr.row-in { animation: row-in-up .28s ease both; animation-delay: calc(var(--i, 0) * 24ms + .3s); }

@media (max-width: 640px) {
  .duel { gap: 4px; padding: 8px; }
  .duel-side b { font-size: 15px; }
  .duel-side span { font-size: 11px; }
  .duel-mid img { width: 58px; height: 58px; }
  .duel-mid span { font-size: 17px; }
  .dmg { font-size: 13px; }
  .powerbar { margin-top: 5px; font-size: 12px; }
}

/* ---------- Phát trận thật trong trang ---------- */
.theater { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: #020a08; animation: duel-in .2s ease-out both; }
.th-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--jade-line); }
.th-bar b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 16px/1.2 var(--title); color: var(--gold-2); }
.th-bar .gbtn { flex: none; }
.th-stage { position: relative; flex: 1; min-height: 0; }
.th-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.th-load { position: absolute; inset: 0; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; font: 700 22px/1.3 var(--title); color: var(--gold-2); }
.th-load span { font: 400 13.5px/1.4 var(--body); color: var(--ink-2); }
.watch-toggle { grid-column: 1 / -1; justify-self: center; margin-top: 6px; padding: 3px 12px; border: 1px solid var(--jade-line); border-radius: 12px; background: rgba(0, 0, 0, .5); color: var(--ink-2); font: 400 12.5px/1.4 var(--body); cursor: pointer; }
.watch-toggle[aria-pressed="true"] { color: var(--gold-2); border-color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
