/* Layar tarung (paket U). Memakai variabel tema dari style.css. */

.screen-battle {
  position: fixed; inset: var(--topbar) 0 0 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #1d1830 0%, #0d0b14 70%);
  --party-w: 220px; --log-w: 270px; --bar-h: 92px; --sk: 68px; --gap: 8px;
  color: var(--ink); user-select: none; -webkit-user-select: none;
}
/* Panggung papan: kanvas 3D/2D (dibuat board.js) mengisi penuh; lapisan DOM papan (.b3d-overlay) di atasnya. */
.screen-battle .bt-stage {
  position: absolute; inset: 0; touch-action: none; outline: none; cursor: default;
}
.screen-battle .bt-stage:focus-visible { box-shadow: inset 0 0 0 2px rgba(241, 214, 142, .6); }
.screen-battle .bt-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
/* Vignette lembut + sapuan tepi giliran (mine emas, ally biru, enemy merah); tidak menangkap pointer. */
.screen-battle .bt-stage::before, .screen-battle .bt-stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
}
.screen-battle .bt-stage::before { background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, .38) 100%); }
/* Lapisan label papan (nama/HP, angka melayang) di atas vignette supaya tidak ikut menggelap. */
.screen-battle .bt-stage > .b3d-overlay { z-index: 2; }
.screen-battle .bt-stage::after { box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .3s ease-out; }
.screen-battle[data-turn="mine"] .bt-stage::after { box-shadow: inset 0 0 70px 4px rgba(241, 214, 142, .32); }
.screen-battle[data-turn="ally"] .bt-stage::after { box-shadow: inset 0 0 70px 4px rgba(110, 168, 240, .3); }
.screen-battle[data-turn="enemy"] .bt-stage::after { box-shadow: inset 0 0 70px 4px rgba(214, 80, 62, .32); }

.bt-panel-base,
.bt-top > *, .bt-pcard, .bt-log, .bt-bar, .bt-preview, .bt-tip, .bt-mode, .bt-bossbar, .bt-cam-btn {
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}

/* ---------- Bilah atas: ronde, inisiatif, tujuan ---------- */
.bt-top {
  position: absolute; top: var(--gap); left: calc(var(--party-w) + var(--gap) * 2);
  right: calc(var(--gap) * 2 + 48px); display: flex; align-items: center; gap: 8px;
  pointer-events: none; min-width: 0;
}
.screen-battle[data-log="open"] .bt-top { right: calc(var(--log-w) + var(--gap) * 2); }
.bt-top > * { pointer-events: auto; }
.bt-round {
  flex: none; padding: 6px 12px; border-radius: 10px; font-weight: bold; color: var(--gold-hi);
  white-space: nowrap; font-size: .95rem;
}
.bt-init {
  flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; margin: 0; padding: 6px 10px; list-style: none;
  border-radius: 12px; overflow: visible; justify-content: flex-start;
}
.bt-init-item {
  --pc: #6fc7b8; position: relative; flex: none; width: var(--init-sz, 40px); height: var(--init-sz, 40px); border-radius: 50%;
  overflow: visible; cursor: pointer; transition: transform .2s;
}
.bt-init-item > svg {
  width: 100%; height: 100%; border-radius: 50%; display: block;
  box-shadow: 0 0 0 2px var(--pc), 0 2px 6px rgba(0, 0, 0, .6); background: #2a2233;
}
.bt-init-item.side-enemy { --pc: #c0503f; }
.bt-init-item.is-mine > svg { box-shadow: 0 0 0 2px var(--pc), 0 0 0 4px rgba(241, 214, 142, .55); }
.bt-init-item.is-active { transform: scale(1.18); z-index: 1; }
.bt-init-item.is-active > svg { box-shadow: 0 0 0 3px var(--gold-hi), 0 0 14px rgba(241, 214, 142, .7); }
.bt-init-item.is-active::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--gold-hi); border-bottom: 0;
}
.bt-init-item.is-down > svg { filter: saturate(.3) brightness(.7); }
.bt-init-item.is-gone { opacity: .35; }
.bt-obj {
  flex: 0 1 auto; min-width: 0; max-width: 300px; padding: 5px 10px; border-radius: 10px; font-size: .82rem;
  display: flex; flex-direction: column; line-height: 1.2;
}
.bt-skill, .bt-obj { font-size-adjust: none; }
.bt-skill { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.bt-obj-k { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.bt-obj-v {
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.15;
}
.bt-abort-top { flex: none; font-size: .8rem; padding: 4px 10px; min-height: 34px; }

/* ---------- Bilah bos ---------- */
.bt-bossbar {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%); display: flex; align-items: center;
  gap: 10px; padding: 6px 14px; border-radius: 10px; border-color: #8a6a2a; pointer-events: none;
  max-width: calc(100% - 2 * var(--party-w) - 48px);
}
.bt-boss-name { font-weight: bold; color: #ffcf7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-boss-segs { display: flex; gap: 3px; flex: none; }
.bt-boss-seg { width: 34px; height: 10px; border-radius: 3px; background: #3a2a22; box-shadow: inset 0 0 0 1px #5b3a2a; }
.bt-boss-seg.is-on { background: linear-gradient(180deg, #ff8a5c, #b8321f); }

/* ---------- Panel party ---------- */
.bt-party {
  position: absolute; top: var(--gap); left: var(--gap); width: var(--party-w);
  bottom: calc(var(--bar-h) + var(--gap) * 2); display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; scrollbar-width: thin; pointer-events: auto;
}
.bt-pcard {
  --pc: #a99c80; --hero: #888; display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 7px;
  border-radius: 10px; border-left: 4px solid var(--pc); cursor: pointer; position: relative; flex: none;
}
.bt-pcard:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.bt-pcard.is-active { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 16px rgba(241, 214, 142, .35); }
.bt-pcard.is-mine::after {
  content: '★'; position: absolute; top: 4px; right: 6px; font-size: .7rem; color: var(--gold-hi);
}
.bt-pcard.is-down .bt-pc-portrait { filter: saturate(.25); box-shadow: 0 0 0 2px #e0715f; }
.bt-pcard.is-dead, .bt-pcard.is-escaped { opacity: .5; }
.bt-pcard.is-dead .bt-pc-portrait { filter: grayscale(1) brightness(.6); }
.bt-pc-portrait {
  --hp: 100; width: 52px; height: 52px; border-radius: 8px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--hero) 70%, #fff 0%), #1a1520);
}
.bt-pc-portrait > svg { width: 100%; height: 100%; display: block; }
.bt-pc-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bt-pc-name { font-weight: bold; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-pc-class { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-pc-state { font-size: .74rem; color: #ff9b85; font-weight: bold; }
.bt-hp {
  --hp: 100%; position: relative; height: 14px; border-radius: 7px; background: #241a1a;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6); overflow: hidden; margin-top: 2px;
}
.bt-hp-fill {
  position: absolute; inset: 0 auto 0 0; width: var(--hp);
  background: linear-gradient(180deg, #9ee27f, #4f9a3a); transition: width .35s ease;
}
.bt-hp.is-mid .bt-hp-fill { background: linear-gradient(180deg, #f1d36a, #b8902a); }
.bt-hp.is-low .bt-hp-fill { background: linear-gradient(180deg, #ff8a72, #b8321f); }
.bt-hp-num {
  position: relative; display: block; text-align: center; font: bold 10px/14px var(--mono);
  color: #fff; text-shadow: 0 1px 1px #000, 0 0 2px #000;
}
.bt-sts { display: flex; flex-wrap: wrap; gap: 2px; min-height: 0; }
.bt-st { position: relative; width: 20px; height: 20px; }
.bt-st > svg { width: 20px; height: 20px; display: block; }
.bt-st-t {
  position: absolute; right: -3px; bottom: -3px; font: bold 9px/1 var(--mono); color: #fff;
  background: #000a; border-radius: 4px; padding: 1px 2px;
}
.bt-pc-owner { display: flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--muted); min-width: 0; }
.bt-pc-owner > span:not(.bt-ai) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-owner-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.bt-ai {
  flex: none; font: bold 9px/1 var(--mono); padding: 2px 4px; border-radius: 4px;
  background: #3b5b7a; color: #dff1ff;
}

/* ---------- Catatan ---------- */
.bt-log {
  position: absolute; top: var(--gap); right: var(--gap); width: var(--log-w);
  bottom: calc(var(--bar-h) + var(--gap) * 2); border-radius: 12px; display: flex; flex-direction: column;
  overflow: hidden;
}
.screen-battle[data-log="closed"] .bt-log { display: none; }
.bt-log-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.bt-log-title { margin: 0; font-size: .9rem; color: var(--gold-hi); }
.bt-log-list {
  flex: 1; margin: 0; padding: 6px 8px; list-style: none; overflow-y: auto; font-size: .8rem; line-height: 1.35;
  scrollbar-width: thin; user-select: text; -webkit-user-select: text;
}
.bt-log-item { padding: 2px 0 2px 8px; border-left: 2px solid transparent; }
.bt-log-item.is-round { color: var(--gold-hi); font-weight: bold; border-left-color: var(--gold); margin-top: 4px; }
.bt-log-item.is-turn { color: var(--muted); }
.bt-log-item.is-roll { color: #c9c1e6; font-family: var(--mono); font-size: .74rem; }
.bt-log-item.is-dmg, .bt-log-item.is-hit { color: #ffb4a3; }
.bt-log-item.is-crit { color: #ffd46a; font-weight: bold; border-left-color: #ffd46a; }
.bt-log-item.is-miss { color: #a7a2b0; }
.bt-log-item.is-heal { color: #a7e98f; }
.bt-log-item.is-status, .bt-log-item.is-surface { color: #9fd3ff; }
.bt-log-item.is-down { color: #ff8a72; font-weight: bold; }
.bt-log-item.is-phase { color: #ff9b5a; font-weight: bold; border-left-color: #ff9b5a; }
.bt-help { margin: 0; padding: 6px 10px; font-size: .68rem; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- Kamera ---------- */
.bt-cam {
  position: absolute; right: var(--gap); top: calc(var(--gap) + 60px); display: flex; flex-direction: column; gap: 6px;
}
.screen-battle:not([data-board="3d"]) .bt-cam-rot { display: none; }
/* Papan gagal dimuat (2D pun): pesan + tombol muat ulang di atas papan. */
.bt-boardfail {
  position: absolute; left: 50%; top: 40%; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; max-width: calc(100% - 24px);
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b)); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .55);
}
.bt-boardfail[hidden] { display: none; }
.bt-boardfail-txt { color: var(--ink); font-size: .9rem; }
.bt-reload { min-height: 40px; padding: 4px 14px; }
.bt-cam { z-index: 5; }
/* Popover grafis: di kiri deretan tombol kamera. */
.bt-gfx {
  position: absolute; right: 48px; top: 0; z-index: 6; width: max-content; max-width: min(300px, calc(100vw - 120px));
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b)); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .55); color: var(--ink);
}
.bt-gfx[hidden] { display: none; }
.bt-gfx-title { margin-bottom: 4px; font-size: .75rem; color: var(--muted); }
.bt-gfx-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.bt-gfx-opt {
  min-width: 52px; min-height: 36px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05); color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer;
}
.bt-gfx-opt[aria-pressed="true"] { border-color: var(--gold); background: rgba(214, 178, 94, .22); color: var(--gold-hi); }
.bt-gfx-opt:hover:not(:disabled) { border-color: var(--gold); }
.bt-gfx-opt:disabled { opacity: .55; cursor: wait; }
.screen-battle[data-log="open"] .bt-cam { right: calc(var(--log-w) + var(--gap) * 2); }
.bt-cam-btn, .bt-log-toggle {
  width: 40px; height: 40px; border-radius: 10px; color: var(--gold-hi); font-size: 1.2rem; font-weight: bold;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.bt-log-toggle {
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b)); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.screen-battle[data-log="open"] .bt-log-toggle { border-color: var(--gold); background: rgba(214, 178, 94, .2); }
.bt-cam-btn:hover, .bt-log-toggle:hover { border-color: var(--gold); }

/* ---------- Bilah bawah ---------- */
.bt-bar {
  position: absolute; left: var(--gap); right: var(--gap); bottom: var(--gap); height: var(--bar-h);
  border-radius: 14px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
}
.bt-active { flex: 0 0 auto; width: 250px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bt-act-portrait {
  flex: none; width: 60px; height: 60px; border-radius: 50%; overflow: hidden; background: #2a2233;
  box-shadow: 0 0 0 2px var(--line);
}
.screen-battle[data-turn="mine"] .bt-act-portrait { box-shadow: 0 0 0 3px var(--gold-hi), 0 0 16px rgba(241, 214, 142, .5); }
.screen-battle[data-turn="enemy"] .bt-act-portrait { box-shadow: 0 0 0 3px #c0503f; }
.bt-act-portrait > svg { width: 100%; height: 100%; display: block; }
.bt-act-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bt-act-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-act-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-battle[data-turn="mine"] .bt-act-sub { color: var(--gold-hi); }
.bt-act-pips { display: flex; gap: 6px; font-size: .72rem; }
.bt-act-pips[hidden] { display: none; }
.bt-pip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px; border-radius: 999px;
  border: 1px solid currentColor; line-height: 1.35; white-space: nowrap; transition: opacity .2s;
}
.bt-pip-ico { font-style: normal; font-size: .8rem; }
.bt-pip-action { color: #ffcf6a; background: rgba(255, 207, 106, .1); }
.bt-pip-bonus { color: #7fd6ff; background: rgba(127, 214, 255, .1); }
.bt-pip.is-spent { color: #6a6070; background: none; text-decoration: line-through; opacity: .7; }
.bt-timer { position: relative; flex: none; width: 44px; height: 44px; }
.bt-timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.bt-timer-bg { fill: rgba(0, 0, 0, .35); stroke: #3a3242; stroke-width: 4; }
.bt-timer-fg { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.bt-timer.is-low .bt-timer-fg { stroke: #ff6a4f; }
.bt-timer-num { position: absolute; inset: 0; display: grid; place-items: center; font: bold 13px var(--mono); }
.bt-timer.is-low .bt-timer-num { color: #ff8a72; }

.bt-skills {
  flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; gap: 6px; overflow-x: auto;
  padding: 4px 2px; scrollbar-width: none;
}
.bt-skills::-webkit-scrollbar { display: none; }
.bt-skill {
  --elc: #d6b25e; position: relative; flex: none; width: var(--sk); height: var(--sk); border-radius: 10px;
  border: 1px solid #7a6238; background: linear-gradient(180deg, #3d3124, #231b14); color: var(--ink);
  cursor: pointer; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font); transition: transform .12s, box-shadow .12s, border-color .12s; overflow: hidden;
}
/* Status lewat data-state (ready/wait/cd/na); tanpa opacity supaya kontras teks terjaga */
.bt-skill[data-state="ready"] { border-color: color-mix(in srgb, var(--elc) 70%, #7a6238); box-shadow: inset 0 -3px 0 var(--elc), 0 2px 6px rgba(0, 0, 0, .5); }
.bt-skill[data-state="ready"]:hover { border-color: var(--gold-hi); transform: translateY(-2px); box-shadow: inset 0 -3px 0 var(--elc), 0 0 12px rgba(241, 214, 142, .35); }
.bt-skill[data-state="wait"] { filter: saturate(.45) brightness(.9); }
.bt-skill[data-state="na"] { background: #1b1612; border-color: #4a3d2c; cursor: not-allowed; }
.bt-skill[data-state="na"] .bt-sk-ico { opacity: .4; filter: grayscale(1); }
/* Nama di atas arsir ::after: arsir hanya menggelapkan latar, bukan teks (kontras ≥ 6.7:1). */
.bt-skill[data-state="na"] .bt-sk-name { color: #a89d88; position: relative; z-index: 1; }
.bt-skill[data-state="na"]::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0, 0, 0, .45) 6px 9px);
}
.bt-sk-na { position: absolute; right: 4px; bottom: 3px; font: bold 13px/1 var(--font); color: #ff8a7a; text-shadow: 0 1px 2px #000; z-index: 1; }
.bt-skill[data-state="cd"] { background: #1b1612; border-color: #4a3d2c; }
.bt-skill[data-state="cd"] .bt-sk-ico, .bt-skill[data-state="cd"] .bt-sk-name { opacity: .3; }
.bt-sk-cdn {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; border-radius: inherit;
  font: 800 26px/1 var(--mono); color: #ffffff; text-shadow: 0 0 3px #000, 0 2px 4px #000;
  background: radial-gradient(circle, rgba(0, 0, 0, .6) 0 42%, rgba(0, 0, 0, .2) 72%);
}
.bt-skill:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
/* Menimpa button:disabled global (style.css) yang meredupkan lewat opacity; tampilan diatur data-state */
.bt-skill:disabled { opacity: 1; }
.bt-skill.is-sel {
  border: 2px solid #fff3c4; background: linear-gradient(180deg, #6a532c, #2e2416); transform: translateY(-3px);
  box-shadow: inset 0 3px 0 #fff3c4, 0 0 0 3px var(--gold-hi), 0 0 18px 2px rgba(241, 214, 142, .75);
}
.bt-skill.is-ult { border-color: #b48cf0; background: linear-gradient(180deg, #44305a, #1f1629); }
.bt-skill.is-ult[data-state="ready"] { box-shadow: inset 0 -3px 0 #c9a6ff, 0 0 10px rgba(180, 140, 240, .55); animation: bt-ult 2.4s ease-in-out infinite; }
@keyframes bt-ult { 50% { box-shadow: inset 0 -3px 0 #c9a6ff, 0 0 18px rgba(180, 140, 240, .85); } }
.bt-sk-ult { position: absolute; right: 4px; bottom: 3px; font: bold 13px/1 var(--font); color: #e3ccff; text-shadow: 0 1px 2px #000; }
/* Ult tak bisa dipakai: ⊘ mengambil pojok kanan-bawah; bingkai ungu is-ult tetap menandai ult. */
.bt-skill[data-state="na"] .bt-sk-ult { display: none; }
.bt-skill.el-fire { --elc: #ff8a4a; } .bt-skill.el-cold { --elc: #8fd8ff; } .bt-skill.el-lightning { --elc: #ffe66a; }
.bt-skill.el-poison { --elc: #8fe36a; } .bt-skill.el-radiant { --elc: #fff1b0; } .bt-skill.el-psychic { --elc: #d08fff; }
.bt-skill.el-water { --elc: #5fb3ff; } .bt-skill.el-oil { --elc: #b08a5a; } .bt-skill.el-physical { --elc: #e6d7b8; }
.bt-sk-num { position: absolute; top: 3px; left: 5px; font: bold 11px var(--mono); color: #d9cdb0; }
.bt-sk-ico { font-size: 1.4rem; line-height: 1; color: var(--elc); text-shadow: 0 0 8px color-mix(in srgb, var(--elc) 60%, transparent), 0 1px 2px #000; }
.bt-sk-name {
  font-size: 11px; line-height: 1.15; color: #efe6d2; max-width: calc(var(--sk) - 6px); margin-top: 3px; text-align: center;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}
.bt-sk-cost { position: absolute; top: 3px; right: 5px; font-size: 11px; }
.bt-sk-cost.is-action { color: #ffcf6a; }
.bt-sk-cost.is-bonus { color: #7fd6ff; }
.bt-end {
  flex: none; min-width: 120px; height: 60px; border-radius: 12px; padding: 0 14px; cursor: pointer;
  font: bold 1rem var(--font); color: #2a1d08; border: 1px solid #f1d68e;
  background: linear-gradient(180deg, #f1d68e, #c79a3d); box-shadow: 0 0 12px rgba(241, 214, 142, .25);
}
.bt-end:disabled { background: linear-gradient(180deg, #5a4d36, #3a3123); color: #a99c80; border-color: #5e4a2a; box-shadow: none; }
.screen-battle[data-turn="mine"][data-locked="0"] .bt-end:not(:disabled) { animation: bt-glow 1.8s ease-in-out infinite; }
@keyframes bt-glow { 50% { box-shadow: 0 0 22px rgba(241, 214, 142, .7); } }

/* ---------- Mode target ---------- */
.bt-mode {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-h) + var(--gap) * 2);
  display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 14px; border-radius: 999px;
  border-color: var(--gold); max-width: calc(100% - 32px); font-size: .88rem;
}
.bt-mode-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gold-hi); }
.bt-mode-cancel { min-height: 32px; padding: 2px 12px; font-size: .82rem; flex: none; }

/* ---------- Pratinjau & tooltip ---------- */
.bt-preview, .bt-tip {
  position: absolute; z-index: 5; border-radius: 10px; padding: 8px 11px; pointer-events: none;
  max-width: 260px; font-size: .82rem; line-height: 1.35;
}
.bt-preview { border-color: var(--gold); min-width: 150px; }
.bt-preview.is-bad { border-color: #c0503f; }
.bt-pv-title, .bt-tip-title { font-weight: bold; color: var(--gold-hi); }
.bt-pv-target { color: var(--ink); font-weight: bold; }
.bt-pv-chance { font-size: 1.1rem; font-weight: bold; color: #fff; }
.bt-pv-adv { color: #9ee27f; }
.bt-pv-dis, .bt-pv-warn, .bt-tip-warn { color: #ff9b85; font-weight: bold; }
.bt-preview.is-bad .bt-pv-line { color: #ff9b85; }
.bt-pv-hits { margin: 4px 0 0; padding: 0 0 0 14px; font-size: .76rem; }
.bt-pv-hits .is-ally { color: #ff9b85; }
.bt-tip-line { color: var(--ink); }
.bt-tip-st { color: #9fd3ff; font-size: .76rem; }
.bt-tip { white-space: pre-line; }
.bt-tip.is-card { max-width: 280px; }
.bt-tip-pas { color: var(--gold-hi); margin-top: 4px; font-weight: bold; }
.bt-tip-desc { color: var(--ink); font-size: .76rem; opacity: .9; }
.bt-cam-btn[aria-pressed="true"] { border-color: var(--gold); background: rgba(214, 178, 94, .22); }

/* ---------- Banner ---------- */
.bt-banner {
  position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  padding: 10px 30px; border-radius: 14px; font-size: 1.6rem; font-weight: bold; text-align: center;
  color: var(--gold-hi); background: linear-gradient(90deg, transparent, rgba(20, 14, 8, .9) 15%, rgba(20, 14, 8, .9) 85%, transparent);
  text-shadow: 0 2px 6px #000; white-space: nowrap; letter-spacing: .04em;
}
.bt-banner.is-on { animation: bt-banner-in .35s ease-out; }
.bt-banner.is-mine { font-size: 2rem; color: #fff3c4; text-shadow: 0 0 18px rgba(241, 214, 142, .8), 0 2px 6px #000; }
.bt-banner.is-phase {
  white-space: normal; max-width: min(720px, 88vw); font-size: 1.25rem; color: #ffd0a8;
  background: linear-gradient(90deg, transparent, rgba(60, 12, 6, .92) 10%, rgba(60, 12, 6, .92) 90%, transparent);
  padding: 16px 40px;
}
@keyframes bt-banner-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ---------- Dadu ---------- */
.dice-layer { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.dice-roll { position: absolute; width: 0; height: 0; }
.dice-row { position: absolute; left: 0; top: 0; display: flex; gap: 110px; transform-style: preserve-3d; }
.dice-row:has(> .d20:nth-child(2)) { left: -55px; }
.d20 { position: relative; width: 0; height: 0; perspective: 700px; transition: opacity .25s; }
.d20-body { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.d20-face {
  position: absolute; transform-origin: 50% 66.667%; backface-visibility: hidden;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(165deg, #fff6dc 0%, #e9cf8f 55%, #b48a3e 100%);
}
.d20.is-other .d20-face { background: linear-gradient(165deg, #e6e2f0 0%, #b9b2cc 55%, #77708c 100%); }
.d20-num {
  position: absolute; left: 0; right: 0; top: 44%; text-align: center; font: bold 15px/1 var(--font);
  color: #3a2408; text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.d20-num.is-under { text-decoration: underline; }
.d20.is-dropped { opacity: .4; }
.dice-roll.is-landed .d20.is-chosen { filter: drop-shadow(0 0 10px rgba(255, 220, 120, .9)); }
.dice-roll.is-crit .d20.is-chosen { filter: drop-shadow(0 0 18px #ffd84a) drop-shadow(0 0 6px #fff); }
.dice-roll.is-crit .d20.is-chosen .d20-face { background: linear-gradient(165deg, #fffbe0, #ffd84a 60%, #c99312); }
.dice-roll.is-fumble .d20.is-chosen .d20-face { background: linear-gradient(165deg, #f0c4b8, #c0503f 60%, #6a1a10); }
.dice-roll.is-fumble .d20.is-chosen .d20-num { color: #fff; text-shadow: 0 1px 2px #000; }
.dice-roll.is-fumble.is-landed::after {
  content: ''; position: absolute; left: -34px; top: -34px; width: 68px; height: 68px; pointer-events: none;
  background: #ff3a1f; opacity: .85;
  clip-path: polygon(48% 0, 54% 0, 50% 30%, 64% 44%, 52% 62%, 60% 100%, 55% 100%, 46% 63%, 57% 45%, 44% 31%);
}
.dice-label {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%); white-space: nowrap;
  padding: 4px 12px; border-radius: 8px; font: bold .92rem var(--mono); color: #fff;
  background: rgba(14, 10, 20, .88); border: 1px solid var(--gold); animation: bt-fade .2s ease-out;
}
.dice-roll.is-crit .dice-label { color: #ffe27a; border-color: #ffe27a; }
.dice-roll.is-fumble .dice-label { color: #ff9b85; border-color: #c0503f; }
.dice-roll.is-out { opacity: 0; transition: opacity .2s; }
.dice-roll.is-mini, .dice-flat {
  display: grid; place-items: center; transform: translate(-50%, -50%); font: bold 14px var(--mono);
}
.dice-roll.is-mini {
  width: 32px; height: 32px; color: #3a2408; animation: bt-pop .4s ease-out;
  background: linear-gradient(165deg, #fff6dc, #c9a253); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.dice-roll.is-mini.is-crit { background: linear-gradient(165deg, #fffbe0, #ffd84a); }
.dice-roll.is-mini.is-fumble { background: linear-gradient(165deg, #f0c4b8, #c0503f); color: #fff; }
.dice-flat {
  position: absolute; left: 0; top: 0; width: 56px; height: 56px; font-size: 22px; color: #3a2408;
  background: linear-gradient(165deg, #fff6dc, #c9a253); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  animation: bt-fade .2s ease-out;
}
.dice-roll.is-flat .dice-label { top: 34px; }
.dice-roll.is-crit .dice-flat { background: linear-gradient(165deg, #fffbe0, #ffd84a); }
.dice-roll.is-fumble .dice-flat { background: linear-gradient(165deg, #f0c4b8, #c0503f); color: #fff; }
@keyframes bt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bt-pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 60% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); } 100% { transform: translate(-50%, -80%) scale(1); } }

/* ---------- Layar hasil & rusak ---------- */
.bt-result, .bt-broken, .bt-confirm {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 4, 10, .72); backdrop-filter: blur(2px);
}
.bt-result[hidden], .bt-broken[hidden], .bt-confirm[hidden] { display: none; }
/* Kartu kolom: tabel yang menggulir, tombol lanjut selalu terlihat di bawah. */
.bt-res-card {
  width: min(760px, 100%); max-height: 100%; overflow: hidden; padding: 18px 20px; border-radius: 16px;
  text-align: center; animation: bt-banner-pop .35s ease-out; display: flex; flex-direction: column; min-height: 0;
}
.bt-res-card > * { flex: none; }
.bt-res-card > .bt-res-tablewrap { flex: 0 1 auto; min-height: 0; overflow: auto; }
@keyframes bt-banner-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.bt-res-title { margin: 0; font-size: 2.1rem; letter-spacing: .05em; }
.bt-res-card.is-win .bt-res-title { color: var(--gold-hi); text-shadow: 0 0 20px rgba(241, 214, 142, .55); }
.bt-res-card.is-lose .bt-res-title { color: #ff9b85; }
.bt-res-reason { margin: 4px 0 0; color: var(--ink); }
.bt-res-rounds { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.bt-res-mvps { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 4px; }
.bt-mvp {
  display: grid; grid-template-columns: 44px auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  text-align: left; padding: 6px 12px 6px 6px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25);
}
.bt-mvp > svg { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 50%; }
.bt-mvp-k { font-size: .7rem; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
.bt-mvp-v { font-weight: bold; }
.bt-res-sub { margin: 12px 0 6px; font-size: .95rem; color: var(--gold-hi); }
.bt-res-table thead th { position: sticky; top: 0; background: var(--panel-b); z-index: 1; }
.bt-res-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.bt-res-table th, .bt-res-table td { padding: 5px 6px; border-bottom: 1px solid rgba(94, 74, 42, .5); white-space: nowrap; }
.bt-res-table thead th { color: var(--muted); font-weight: normal; font-size: .72rem; }
.bt-res-table td { font-family: var(--mono); text-align: center; }
.bt-res-hero { display: flex; align-items: center; gap: 8px; text-align: left; }
.bt-res-hero > svg { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.bt-res-name { display: flex; flex-direction: column; line-height: 1.15; }
.bt-res-name small { color: var(--muted); font-weight: normal; }
.bt-res-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.bt-continue { min-height: 44px; padding: 6px 26px; }
.bt-res-wait { color: var(--muted); margin: 0; }
.bt-broken-msg { margin: 0 0 12px; font-size: 1.05rem; }
.bt-confirm-card { width: min(380px, 100%); }
.bt-confirm-msg { margin: 0 0 14px; font-size: 1.05rem; }
.bt-confirm-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Tablet (lebar ≤ 1200) ---------- */
@media (max-width: 1200px) {
  .screen-battle { --party-w: 190px; }
  .bt-active { width: 240px; }
  .bt-obj { max-width: 200px; }
}
@media (max-width: 900px) {
  .screen-battle { --party-w: 160px; --sk: 56px; }
  .bt-active { width: 170px; }
  .bt-pip-txt { display: none; }
  .bt-timer { width: 38px; height: 38px; }
  .bt-end { min-width: 96px; }
  .bt-obj { display: none; }
}

/* ---------- HP miring (tinggi ≤ 500) ---------- */
@media (max-height: 500px) {
  .screen-battle { --party-w: 48px; --bar-h: 50px; --sk: 42px; --gap: 5px; --log-w: 240px; }
  .bt-top { gap: 6px; }
  .bt-round { padding: 3px 8px; font-size: .78rem; }
  .bt-init { padding: 3px 6px; gap: 4px; }
  .bt-init-item { width: var(--init-sz, 30px); height: var(--init-sz, 30px); }
  .bt-init-item.is-active { transform: scale(1.12); }
  .bt-obj { display: none; }
  .bt-abort-top { min-height: 30px; padding: 2px 8px; font-size: .72rem; }
  .bt-bossbar { top: 46px; padding: 3px 10px; font-size: .8rem; }
  .bt-boss-seg { width: 22px; height: 8px; }
  .bt-party { gap: 4px; }
  .bt-pcard { grid-template-columns: 44px; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; width: 44px; }
  .bt-pcard.is-mine::after { top: -2px; right: -2px; }
  .bt-pc-body { display: none; }
  .bt-pc-portrait {
    width: 44px; height: 44px; border-radius: 50%; padding: 3px;
    background: conic-gradient(#7fcf6a calc(var(--hp) * 1%), #3a2a2a 0);
  }
  .bt-pc-portrait > svg { border-radius: 50%; background: #1a1520; }
  .bt-pcard.is-active .bt-pc-portrait { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 10px rgba(241, 214, 142, .6); }
  .bt-pcard.is-active { box-shadow: none; }
  .bt-log { bottom: calc(var(--bar-h) + var(--gap) * 2); z-index: 4; }
  .bt-help { display: none; }
  .bt-tip.is-card { max-width: 230px; font-size: .76rem; }
  /* Delapan tombol kamera: dua kolom supaya tidak menabrak bilah bawah. */
  .bt-cam { top: calc(var(--gap) + 36px); gap: 4px; display: grid; grid-template-columns: repeat(2, 36px); }
  .bt-gfx { right: 84px; top: 0; padding: 8px; gap: 6px; }
  .bt-gfx-opt { min-height: 40px; padding: 2px 8px; }
  .bt-cam-btn, .bt-log-toggle { width: 36px; height: 36px; font-size: .95rem; }
  .bt-bar { padding: 0 6px; gap: 6px; border-radius: 10px; }
  .bt-active { width: auto; gap: 6px; }
  .bt-act-portrait { width: 34px; height: 34px; }
  .bt-act-info { display: none; }
  .bt-timer { width: 36px; height: 36px; }
  .bt-sk-name { display: none; }
  .bt-sk-ico { font-size: 1.15rem; }
  .bt-sk-cdn { font-size: 20px; }
  .bt-sk-ult, .bt-sk-na { font-size: 11px; right: 2px; bottom: 1px; }
  .bt-sk-num { font-size: 11px; top: 1px; left: 3px; }
  .bt-sk-cost { font-size: 11px; top: 1px; right: 3px; }
  .bt-end { min-width: 84px; height: 42px; font-size: .85rem; padding: 0 8px; }
  .bt-mode { font-size: .8rem; }
  .bt-preview { top: 44px !important; right: 54px; left: auto !important; max-width: 220px; font-size: .76rem; }
  .bt-banner { font-size: 1.2rem; top: 30%; }
  .bt-banner.is-mine { font-size: 1.5rem; }
  .bt-banner.is-phase { font-size: 1rem; padding: 10px 24px; }
  /* Hasil tarung ringkas: keempat baris pahlawan terlihat tanpa gulir (MVP/ronde disembunyikan). */
  .bt-res-card { padding: 10px 12px; }
  .bt-res-mvps, .bt-res-sub, .bt-res-rounds, .bt-res-name small { display: none; }
  .bt-res-title { font-size: 1.2rem; }
  .bt-res-reason { margin-top: 0; font-size: .8rem; }
  .bt-res-card > .bt-res-tablewrap { margin-top: 4px; }
  .bt-res-table { font-size: .74rem; }
  .bt-res-table th, .bt-res-table td { padding: 1px 5px; }
  .bt-res-hero > svg { width: 20px; height: 20px; }
  .bt-res-foot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 4px; padding-top: 4px; }
  .bt-continue { min-height: 44px; }
}

/* ---------- Gerak dikurangi ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen-battle .bt-stage::after { transition: none; }
  .bt-banner.is-on, .bt-res-card, .dice-label, .dice-roll.is-mini { animation: none; }
  .screen-battle[data-turn="mine"][data-locked="0"] .bt-end:not(:disabled) { animation: none; }
  .bt-init-item, .bt-skill, .bt-hp-fill, .bt-timer-fg { transition: none; }
  .bt-skill.is-ult[data-state="ready"] { animation: none; }
  .dice-flat { animation: bt-fade .2s ease-out; }
}

/* ---------- Label papan 3D/2D di layar pendek: hanya bilah HP; nama + angka hanya unit aktif ---------- */
.screen-battle.is-short .bt-stage .b3d-bar { margin: -26px 0 0 -24px; width: 48px; }
.screen-battle.is-short .bt-stage .b3d-bar:not(.is-active) .b3d-bar-name,
.screen-battle.is-short .bt-stage .b3d-bar:not(.is-active) .b3d-bar-num { display: none; }
.screen-battle.is-short .bt-stage .b3d-bar.is-active { margin-left: -36px; width: 72px; z-index: 1; }
