:root {
  --bg: #0a0b09;
  --panel: rgba(18, 20, 16, 0.92);
  --panel-strong: #151810;
  --line: #34392b;
  --line-strong: #6f7d48;
  --text: #f2ecd7;
  --muted: #a9a58f;
  --gold: #d7af54;
  --jade: #6ed8a4;
  --red: #e46856;
  --orange: #f59e0b;
  --blue: #70a7e8;
  --violet: #b99af1;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --panel-pad: 14px;
  --panel-gap: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(215, 175, 84, 0.18), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(110, 216, 164, 0.12), transparent 26rem),
    linear-gradient(135deg, #080906 0%, #11130d 54%, #070807 100%);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, select {
  color: var(--text);
  background: #1b1f15;
  border: 1px solid var(--line);
  border-radius: var(--ui-control-radius);
  padding: var(--ui-control-pad-y) var(--ui-control-pad-x);
  font: inherit;
  user-select: none;
  cursor: pointer;
}

button:hover, select:hover { border-color: var(--line-strong); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.app {
  --desktop-scale: 1;
  --viewport-w: 1440px;
  --viewport-h: 900px;
  --ui-font-size: 15px;
  --ui-battle-gap: 10px;
  --ui-board-shell-min-height: 840px;
  --ui-board-wrap-margin-top: 10px;
  --ui-board-wrap-radius: 16px;
  --ui-float-gap: 18px;
  --ui-float-top: 14px;
  --ui-team-width: 300px;
  --ui-focus-width: 320px;
  --ui-ready-width: 320px;
  --ui-ready-top: 350px;
  --ui-turn-width: 340px;
  --ui-extra-side: 380px;
  --ui-team-list-height: 500px;
  --ui-bars-gap: 4px;
  --ui-bars-margin-top: 7px;
  --ui-statline-size: 11px;
  --ui-statline-margin-top: 7px;
  --ui-timeline-gap: 5px;
  --ui-tl-width: 118px;
  --ui-tl-radius: 10px;
  --ui-tl-pad-y: 5px;
  --ui-tl-pad-x: 6px;
  --ui-board-gap: 4px;
  --ui-board-radius: 16px;
  --ui-board-pad: 8px;
  --ui-board-min-height: 760px;
  --ui-board-max-width: calc((var(--viewport-h) - 280px) * 1.5);
  --ui-control-radius: 10px;
  --ui-control-pad-y: 8px;
  --ui-control-pad-x: 11px;
  --ui-panel-radius: 18px;
  --ui-topbar-pad-y: 12px;
  --ui-topbar-pad-x: 14px;
  --ui-eyebrow-size: 12px;
  --ui-title-size: 30px;
  --ui-h2-size: 17px;
  --ui-h3-size: 15px;
  --ui-sub-size: 12px;
  --ui-small-size: 12px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  gap: 8px;
  font-size: var(--ui-font-size);
}

.app.battle-started {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  max-width: none;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr);
}

.app.device-desktop {
  --ui-font-size: calc(15px * var(--desktop-scale));
  --ui-control-radius: calc(10px * var(--desktop-scale));
  --ui-control-pad-y: calc(8px * var(--desktop-scale));
  --ui-control-pad-x: calc(11px * var(--desktop-scale));
  --ui-panel-radius: calc(18px * var(--desktop-scale));
  --ui-topbar-pad-y: calc(12px * var(--desktop-scale));
  --ui-topbar-pad-x: calc(14px * var(--desktop-scale));
  --ui-eyebrow-size: calc(12px * var(--desktop-scale));
  --ui-title-size: calc(30px * var(--desktop-scale));
  --ui-h2-size: calc(17px * var(--desktop-scale));
  --ui-h3-size: calc(15px * var(--desktop-scale));
  --ui-sub-size: calc(12px * var(--desktop-scale));
  --ui-small-size: calc(12px * var(--desktop-scale));
  --ui-battle-gap: calc(10px * var(--desktop-scale));
  --ui-board-shell-min-height: calc(840px * var(--desktop-scale));
  --ui-board-wrap-margin-top: calc(10px * var(--desktop-scale));
  --ui-board-wrap-radius: calc(16px * var(--desktop-scale));
  --ui-float-gap: calc(18px * var(--desktop-scale));
  --ui-float-top: calc(14px * var(--desktop-scale));
  --ui-team-width: calc(300px * var(--desktop-scale));
  --ui-focus-width: calc(320px * var(--desktop-scale));
  --ui-ready-width: calc(320px * var(--desktop-scale));
  --ui-ready-top: calc(350px * var(--desktop-scale));
  --ui-turn-width: calc(320px * var(--desktop-scale));
  --ui-extra-side: calc(380px * var(--desktop-scale));
  --ui-team-list-height: calc(500px * var(--desktop-scale));
  --ui-bars-gap: calc(4px * var(--desktop-scale));
  --ui-bars-margin-top: calc(7px * var(--desktop-scale));
  --ui-statline-size: calc(11px * var(--desktop-scale));
  --ui-statline-margin-top: calc(7px * var(--desktop-scale));
  --ui-timeline-gap: calc(5px * var(--desktop-scale));
  --ui-tl-width: calc(118px * var(--desktop-scale));
  --ui-tl-radius: calc(10px * var(--desktop-scale));
  --ui-tl-pad-y: calc(5px * var(--desktop-scale));
  --ui-tl-pad-x: calc(6px * var(--desktop-scale));
  --ui-board-gap: calc(4px * var(--desktop-scale));
  --ui-board-radius: calc(16px * var(--desktop-scale));
  --ui-board-pad: calc(8px * var(--desktop-scale));
  --ui-board-min-height: calc(760px * var(--desktop-scale));
  --ui-board-max-width: calc((var(--viewport-h) - calc(280px * var(--desktop-scale))) * 1.5);
}

.topbar, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--ui-panel-radius);
  box-shadow: var(--shadow);
}

.topbar {
  padding: var(--ui-topbar-pad-y) var(--ui-topbar-pad-x);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow {
  color: var(--gold);
  font-size: var(--ui-eyebrow-size);
  letter-spacing: 0.12em;
}

h1, h2, h3 { margin: 0; }
h1 { margin-top: 4px; font-size: var(--ui-title-size); }
h2 { font-size: var(--ui-h2-size); }
h3 { font-size: var(--ui-h3-size); color: var(--gold); }

.sub {
  color: var(--muted);
  line-height: 1.5;
  max-width: 980px;
  margin-top: 5px;
  font-size: var(--ui-sub-size);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-timeline-host {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
}
.topbar-timeline-host:empty {
  display: none;
}
.primary { background: linear-gradient(135deg, #5d4821, #9d7430); border-color: #d7af54; }

.panel { padding: var(--panel-pad); }
.row { display: flex; justify-content: space-between; gap: var(--panel-gap); align-items: flex-start; }
.small { color: var(--muted); font-size: var(--ui-small-size); line-height: 1.55; }
.truncate-line {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.prebattle-stack {
  display: grid;
  gap: 10px;
}

.prebattle-panel {
  position: relative;
  overflow: hidden;
}

.setup-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.setup-env-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  align-items: start;
}

.setup-box {
  position: relative;
  background: rgba(8, 10, 7, 0.62);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.setup-config-box {
  padding-right: min(34vw, 360px);
  border-color: rgba(215, 175, 84, 0.34);
  background:
    linear-gradient(135deg, rgba(215, 175, 84, 0.12), rgba(8, 10, 7, 0.7)),
    rgba(8, 10, 7, 0.72);
}

.setup-launch-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  align-content: start;
  max-width: 240px;
  text-align: right;
}

.setup-config-head,
.setup-duel-card,
.setup-summary-box,
.setup-tab-panel,
.setup-inline-config {
  display: grid;
  gap: 12px;
}

.setup-duel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.setup-enemy-card {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 12px;
  border: 1px solid rgba(215, 175, 84, 0.3);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(215, 175, 84, 0.08), rgba(11, 13, 9, 0.86));
}

.segmented,
.gender-switch,
.setup-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented-pill,
.gender-pill,
.setup-tab {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 18, 13, 0.9);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segmented-pill.active,
.gender-pill.active,
.setup-tab.active {
  border-color: var(--gold);
  background: rgba(215, 175, 84, 0.14);
  color: #f6df9e;
}

.setup-school-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-school-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(111, 125, 72, 0.55);
  border-radius: 999px;
  background: rgba(11, 13, 9, 0.82);
  font-size: 12px;
}

.setup-school-chip em {
  font-style: normal;
  color: var(--gold);
  font-size: 11px;
}

.pve-skill-notes {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #d9d0b5;
}

.pve-skill-notes span {
  padding: 6px 8px;
  border: 1px solid rgba(215, 175, 84, 0.22);
  border-radius: 8px;
  background: rgba(15, 18, 13, 0.72);
}

.setup-secrets {
  padding-top: 8px;
}

.collapse-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  list-style: none;
  cursor: pointer;
}

.collapse-head::-webkit-details-marker {
  display: none;
}

.collapse-toggle {
  color: var(--gold);
  font-size: 12px;
}

.setup-guide-toggle {
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 18, 13, 0.9);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.setup-guide-toggle:hover,
.setup-guide-details[open] .setup-guide-toggle {
  border-color: var(--gold);
  background: rgba(215, 175, 84, 0.14);
  color: #f6df9e;
}

.setup-guide-toggle h3 {
  margin: 0;
}

.setup-guide-toggle .small {
  display: none;
}

.setup-inline-config {
  margin: 10px 0 4px;
  padding: 10px;
  border: 1px solid rgba(111, 125, 72, 0.3);
  border-radius: 14px;
  background: rgba(11, 13, 9, 0.7);
}

.setup-portrait-splash {
  position: absolute;
  right: 18px;
  top: 20px;
  z-index: 2;
  width: min(30vw, 300px);
  aspect-ratio: 1 / 1;
  pointer-events: none;
  opacity: 1;
  transform: none;
}

.setup-portrait-splash::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(215, 175, 84, 0.52);
  border-radius: 18px;
  box-shadow:
    inset 0 0 0 1px rgba(40, 45, 31, 0.86),
    0 16px 38px rgba(0, 0, 0, 0.24);
  background: linear-gradient(135deg, rgba(215, 175, 84, 0.08), rgba(12, 15, 10, 0.08));
}

.setup-portrait-splash img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.34));
}

.setup-portrait-caption {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(8, 10, 7, 0.84);
  border: 1px solid rgba(215, 175, 84, 0.22);
  color: #f2ecd7;
  font-size: 12px;
  text-align: center;
}

.setup-tree-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(0, 1.4fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(111, 125, 72, 0.22);
  border-radius: 16px;
  background: rgba(10, 12, 8, 0.7);
}

.setup-skill-name {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(215, 175, 84, 0.28);
  background: linear-gradient(135deg, rgba(215, 175, 84, 0.12), rgba(15, 18, 13, 0.88));
  color: #f5df9d;
  font-weight: 800;
  text-align: left;
}

.setup-skill-name span {
  color: #bfc7af;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.setup-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
  max-width: calc(100% - min(30vw, 300px) - 28px);
}

.setup-guide-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(111, 125, 72, 0.3);
  border-radius: 12px;
  background: rgba(10, 12, 8, 0.68);
}

.setup-guide-card strong {
  color: #f5df9d;
  font-size: 13px;
}

.setup-guide-card span,
.setup-secret-preview em {
  color: #cfd6c2;
  font-size: 12px;
  line-height: 1.45;
  font-style: normal;
}

.setup-secret-tree {
  position: relative;
  display: grid;
  gap: 8px;
  padding-left: 14px;
}

.setup-secret-tree::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, rgba(215, 175, 84, 0.44), rgba(111, 125, 72, 0.18));
}

.setup-secret-node {
  position: relative;
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 9px 10px 9px 16px;
  border-radius: 13px;
  border: 1px solid rgba(52, 57, 43, 0.9);
  background: rgba(16, 19, 13, 0.82);
}

.setup-secret-node::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 17px;
  width: 8px;
  height: 1px;
  background: rgba(215, 175, 84, 0.38);
}

.setup-secret-node strong,
.setup-secret-node span,
.setup-secret-preview strong,
.setup-secret-preview span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.setup-secret-node strong {
  font-size: 13px;
  color: #f2ecd7;
}

.setup-secret-node span,
.setup-secret-preview span {
  color: var(--muted);
  font-size: 12px;
}

.setup-secret-node.active {
  border-color: var(--gold);
  background: rgba(215, 175, 84, 0.14);
}

.setup-secret-node.unimplemented {
  color: rgba(218, 226, 202, 0.42);
  border-color: rgba(218, 226, 202, 0.12);
  background: rgba(10, 12, 8, 0.42);
  filter: grayscale(0.65);
}

.setup-secret-node.unimplemented strong,
.setup-secret-node.unimplemented span {
  color: rgba(218, 226, 202, 0.42);
}

.setup-secret-preview {
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(215, 175, 84, 0.22);
  border-radius: 14px;
  background: rgba(215, 175, 84, 0.08);
}

.setup-secret-preview strong {
  display: block;
  color: #f5df9d;
  font-size: 14px;
  margin-top: 8px;
}

.setup-secret-preview span {
  display: -webkit-box;
  white-space: normal;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.registry-panel[open] .collapse-toggle {
  color: var(--jade);
}

.battle-stage {
  position: relative;
  display: grid;
  gap: var(--ui-battle-gap);
}

.app.battle-started .battle-stage {
  min-height: 0;
  height: 100%;
  grid-template-rows: 1fr auto;
  padding: 0;
}

.board-shell {
  position: relative;
  min-height: 860px;
}

.app.battle-started .board-shell {
  min-height: 0;
  height: 100%;
}

.board-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.app.battle-started .board-panel {
  height: 100%;
}

/* 战斗开始后隐藏标题行 */
.app.battle-started .board-panel > .row {
  display: none;
}

.battle-board-wrap {
  position: relative;
  margin-top: 12px;
  height: 100%;
}

.app.battle-started .battle-board-wrap {
  margin-top: 0;
  height: 100%;
}

.floating-panel {
  position: absolute;
  z-index: 12;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
}

.draggable-panel {
  left: 0;
  top: 0;
  transform: translate(var(--float-x, 0), var(--float-y, 0));
}

.float-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: -14px -14px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(111, 125, 72, 0.28);
  border-radius: 22px 22px 0 0;
  background: linear-gradient(135deg, rgba(215, 175, 84, 0.08), rgba(15, 18, 13, 0.92));
  cursor: move;
  touch-action: none;
}

.float-content {
  min-width: 0;
  width: 100%;
}

.timeline-float {
  left: 50%;
  top: 16px;
  width: min(780px, calc(100% - 420px));
  transform: translateX(-50%);
}

.timeline-head {
  align-items: center;
}

.team-float {
  right: 18px;
  top: 18px;
  width: min(320px, 29vw);
}

.focus-float {
  width: min(360px, 30vw);
}

.ready-float {
  width: min(320px, 28vw);
}

.turn-float {
  width: min(360px, 30vw);
  max-height: min(76vh, 760px);
  overflow: auto;
}

.ready-float .float-handle,
.turn-float .float-handle {
  position: sticky;
  top: 0;
  z-index: 2;
}

.turn-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.extra-float {
  left: 50%;
  bottom: 18px;
  width: min(620px, calc(100% - 160px));
  transform: translateX(-50%);
  z-index: 11;
}

/* 无可用衔接时隐藏回合外行动 */
.extra-float:not(.active) {
  display: none;
}

.team-list {
  max-height: min(52vh, var(--ui-team-list-height));
}

.selected-portrait {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: auto;
  aspect-ratio: auto;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.selected-portrait.visible {
  opacity: 0.5;
  transform: translateY(0) scale(1);
}

.selected-portrait::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 2px solid rgba(215, 175, 84, 0.34);
  border-radius: 22px;
  box-shadow: inset 0 0 0 1px rgba(58, 64, 43, 0.72);
}

.selected-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  filter: saturate(1.02) contrast(1.03) brightness(1.04) drop-shadow(0 24px 48px rgba(0, 0, 0, 0.48));
  -webkit-mask-image: radial-gradient(ellipse 96% 94% at 50% 50%, #000 54%, rgba(0, 0, 0, 0.82) 68%, rgba(0, 0, 0, 0.26) 86%, transparent 100%);
  mask-image: radial-gradient(ellipse 96% 94% at 50% 50%, #000 54%, rgba(0, 0, 0, 0.82) 68%, rgba(0, 0, 0, 0.26) 86%, transparent 100%);
}

.selected-portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 36%, rgba(5, 6, 4, 0.16) 68%, rgba(5, 6, 4, 0.72) 100%),
    linear-gradient(180deg, rgba(5, 6, 4, 0.24), transparent 18%, transparent 72%, rgba(5, 6, 4, 0.5));
}

.app.device-mobile .setup-env-grid {
  grid-template-columns: 1fr;
}

.app.device-mobile .setup-config-box {
  padding-right: var(--panel-pad);
  overflow: hidden;
}

.app.device-mobile .setup-portrait-splash {
  position: static;
  width: min(72vw, 220px);
  margin: 0 auto;
}

.app.device-mobile .setup-config-head,
.app.device-mobile .setup-summary-box,
.app.device-mobile .setup-inline-config {
  min-width: 0;
}

.app.device-mobile .setup-school-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app.device-mobile .setup-school-chip {
  min-width: 0;
  justify-content: center;
}

.app.device-mobile .setup-effect {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.app.device-mobile .setup-guide {
  grid-template-columns: 1fr;
  max-width: none;
}

.app.device-mobile #registryPanel,
.app.device-mobile #logPanel,
.app.device-mobile .timeline-float:not(.in-topbar),
.app.device-mobile .team-float,
.app.device-mobile .extra-float {
  display: none !important;
}

.app.device-mobile .board {
  --board-min-width: 620px;
  width: max(100%, var(--board-min-width, 0px));
  gap: 3px;
  padding: 6px;
}

.app.device-mobile .battle-board-wrap {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.app.device-mobile .board-panel .board {
  min-height: 520px;
}

.app.device-mobile .selected-portrait.visible {
  opacity: 0.28;
}

.app.device-mobile .board-float-text {
  font-size: 11px;
  padding: 3px 7px;
}

.dragging-float,
.dragging-float * {
  cursor: move !important;
  user-select: none !important;
}

.battle-hud {
  display: grid;
  grid-template-columns: minmax(220px, 0.56fr) minmax(760px, 1.9fr) minmax(300px, 0.68fr);
  gap: 10px;
  align-items: start;
}

.left-rail, .center-stage, .right-rail, .stack { display: grid; gap: 10px; align-content: start; }
.left-rail, .right-rail { position: sticky; top: 10px; }
.unit-list, .skill-list, .registry, .log { display: grid; gap: 8px; }
.scroll { max-height: 540px; overflow: auto; padding-right: 4px; }
.compact-list { max-height: 270px; overflow: auto; padding-right: 4px; }

.unit, .skill, .reg-card {
  position: relative;
  background: rgba(9, 11, 8, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  overflow: hidden;
}

.reg-skill-detail {
  color: #d5dccd;
  font-size: 12px;
  line-height: 1.45;
}

.reg-secret-list {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.reg-secret-list span {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid rgba(111, 125, 72, 0.24);
  border-radius: 10px;
  color: #c6cebb;
  font-size: 11px;
  line-height: 1.35;
  background: rgba(5, 6, 4, 0.34);
}

.reg-secret-list strong {
  color: #f5df9d;
  font-size: 12px;
}

.compact-list .unit {
  padding: 10px;
  border-radius: 12px;
}

.unit.active { border-color: var(--jade); box-shadow: 0 0 0 1px rgba(110, 216, 164, 0.22) inset; }
.unit.current { box-shadow: 0 0 0 1px rgba(215, 175, 84, 0.22) inset, 0 0 24px rgba(215, 175, 84, 0.12); }
.unit.focus { border-color: var(--gold); }
.unit.dead { opacity: 0.42; }

.unit-content {
  position: relative;
  z-index: 1;
}

.unit-portrait-bg {
  position: absolute;
  inset: 0;
  background-image: var(--unit-portrait);
  background-size: cover;
  background-position: center;
  opacity: 1;
  filter: saturate(1.18) contrast(1.08);
}

.unit-portrait-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(9, 11, 8, 0.82) 0%, rgba(9, 11, 8, 0.28) 44%, rgba(9, 11, 8, 0.68) 100%),
    linear-gradient(180deg, rgba(9, 11, 8, 0.04), rgba(9, 11, 8, 0.58));
}

.unit.current .unit-portrait-bg {
  opacity: 1;
}

.unit-head, .skill-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.unit-head {
  align-items: center;
}

.unit-title-block {
  min-width: 0;
}

.unit-head-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.compact-list .unit-head {
  align-items: center;
}

.compact-list .unit-head .small {
  display: none;
}

.school-resource-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  margin: 0;
}

.resource-widget {
  --resource-bg: rgba(10, 12, 8, 0.72);
  flex: 0 0 auto;
}

.sword-qi,
.full-strike {
  display: grid;
  grid-template-columns: repeat(5, 8px);
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(215, 175, 84, 0.38);
  border-radius: 7px;
  background: var(--resource-bg);
}

.sword-qi i,
.full-strike i {
  width: 8px;
  height: 14px;
  border-radius: 3px;
  background: rgba(218, 226, 202, 0.16);
}

.sword-qi i.on {
  background: #d7af54;
  box-shadow: 0 0 8px rgba(215, 175, 84, 0.42);
}

.full-strike {
  border-color: rgba(238, 106, 89, 0.32);
}

.full-strike i.on {
  background: #ee6a59;
}

.full-strike.ready {
  border-color: rgba(238, 106, 89, 0.72);
  box-shadow: 0 0 12px rgba(238, 106, 89, 0.18);
}

.spear-ring,
.glyph-circle {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #d8d0b4;
  background:
    radial-gradient(circle at center, rgba(9, 11, 8, 0.9) 0 54%, transparent 55%),
    conic-gradient(#6f7d48 var(--ring, 0deg), rgba(218, 226, 202, 0.16) 0);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.spear-ring.awakened {
  color: #10120d;
  background:
    radial-gradient(circle at center, #d7af54 0 54%, transparent 55%),
    conic-gradient(#e6c86f var(--ring, 0deg), rgba(218, 226, 202, 0.18) 0);
}

.spear-ring.ready {
  cursor: pointer;
  box-shadow: 0 0 12px rgba(215, 175, 84, 0.3);
}

.medicine-bridge {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(111, 125, 72, 0.42);
  border-radius: 7px;
  background: var(--resource-bg);
}

.medicine-bridge i {
  height: 12px;
  border-radius: 4px;
  background: rgba(218, 226, 202, 0.14);
}

.medicine-bridge .heal.on {
  background: #6ed8a4;
}

.medicine-bridge .martial.on {
  background: #d7af54;
}

.medicine-bridge b {
  position: absolute;
  top: -7px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #10120d;
  background: #f5df9d;
  font-size: 10px;
}

.glyph-circle {
  border: 1px solid rgba(218, 226, 202, 0.22);
  background: rgba(10, 12, 8, 0.72);
}

.glyph-circle.on {
  color: #10120d;
  border-color: transparent;
  background: #6ed8a4;
}

.glyph-circle.yanyun.on {
  background: #8fb7ff;
}

.glyph-circle.meditation.on,
.glyph-circle.xiangguo.on {
  background: #d7af54;
}

.glyph-circle.cihang.on {
  background: #f5df9d;
}

.poison-grid {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(111, 125, 72, 0.42);
  border-radius: 7px;
  background: var(--resource-bg);
}

.poison-grid i {
  border-radius: 3px;
  background: rgba(218, 226, 202, 0.12);
}

.poison-grid .flower.on { background: #ee6a59; }
.poison-grid .snake.on { background: #6ed8a4; }
.poison-grid .scorpion.on { background: #b997ff; }
.poison-grid .spider.on { background: #aeb6aa; }

.bars { display: grid; gap: var(--ui-bars-gap); margin-top: var(--ui-bars-margin-top); }
.bars.compact-bars {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
.barline { height: 7px; background: #272d20; border-radius: 999px; overflow: hidden; }
.fill { height: 100%; }
.hp { background: var(--red); }
.mp { background: var(--blue); }
.qi { background: var(--violet); }
.ep { background: var(--jade); }
.st { background: #8ec07c; }
.tc { background: var(--gold); }

.statline { margin-top: var(--ui-statline-margin-top); color: #d8d0b4; font-size: var(--ui-statline-size); line-height: 1.45; }
.mini-vitals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
}
.mini-vitals span {
  display: grid;
  gap: 1px;
  padding: 4px 5px;
  border: 1px solid #303728;
  border-radius: 8px;
  color: #d8d0b4;
  font-size: 11px;
  line-height: 1.1;
  background: rgba(21, 24, 16, 0.72);
}
.mini-vitals b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  position: relative;
  font-size: 11px;
  padding: 3px 7px;
  border: 1px solid #4a503c;
  border-radius: 999px;
  background: #171a12;
}
.unit-status-area {
  display: grid;
  gap: 5px;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 0;
  width: 100%;
}
.status-chip {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 3px 5px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.1;
}
.status-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-weight: 700;
}
.status-chip em {
  width: 1.2em;
  color: var(--gold);
  font-style: normal;
  text-align: right;
}
.status-chip.empty {
  grid-template-columns: 1fr;
  color: var(--muted);
}
.chip.special {
  border-color: #b89145;
  background: #21180d;
  color: #f8d78b;
}
.chip-toggle {
  appearance: none;
  cursor: pointer;
  font: inherit;
}
.chip-toggle:hover {
  border-color: rgba(215, 175, 84, 0.58);
}
.compact-list .chips {
  max-height: 48px;
  overflow: hidden;
}
.compact-list .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-board-status {
  display: none;
}
.chip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #090b08;
  color: var(--text);
  box-shadow: var(--shadow);
  line-height: 1.45;
  white-space: normal;
}
.chip.warn { color: #facc15; }

.timeline {
  display: flex;
  gap: var(--ui-timeline-gap);
  overflow-x: auto;
  padding-bottom: 2px;
}
.tl {
  flex: 0 0 var(--ui-tl-width);
  border: 1px solid var(--line);
  border-radius: var(--ui-tl-radius);
  padding: var(--ui-tl-pad-y) var(--ui-tl-pad-x);
  background: #12150e;
}
.tl.ready { border-color: var(--gold); }
.tl.current { border-color: var(--jade); background: rgba(110, 216, 164, 0.1); }
.tl.active-turn { box-shadow: 0 0 0 1px rgba(215, 175, 84, 0.18) inset; }

.board {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--ui-board-gap);
  background: rgba(8, 10, 7, 0.46);
  border-radius: var(--ui-board-radius);
  padding: var(--ui-board-pad);
}

.board .cell {
  z-index: 2;
}

.cell {
  aspect-ratio: 1 / 1;
  position: relative;
  border: 1px solid rgba(112, 124, 93, 0.16);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(16, 19, 13, 0.54), rgba(23, 27, 18, 0.58));
  overflow: hidden;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.board-panel .board {
  min-height: auto;
}

.cell.cast-range { background: rgba(112, 167, 232, 0.1); }
.cell.aoe-preview {
  border-color: rgba(112, 167, 232, 0.75);
  background: linear-gradient(135deg, rgba(112, 167, 232, 0.18), rgba(112, 167, 232, 0.06));
  box-shadow: inset 0 0 0 2px rgba(112, 167, 232, 0.24);
}
.cell.has-field-effect {
  background: linear-gradient(135deg, var(--field-tint, rgba(126, 184, 255, 0.13)), var(--field-tint, rgba(126, 184, 255, 0.13))),
    linear-gradient(135deg, rgba(16, 19, 13, 0.54), rgba(23, 27, 18, 0.58));
}
.cell.has-field-barrier {
  box-shadow:
    inset 0 0 0 2px rgba(230, 198, 95, 0.45),
    inset 0 0 28px rgba(230, 198, 95, 0.12);
}
.cell.selectable-target {
  border-color: var(--gold);
  background: rgba(215, 175, 84, 0.16);
  animation: targetPulse 1s ease-in-out infinite;
}
.cell.interrupt-target {
  border-color: rgba(255, 119, 86, 0.92);
  background:
    linear-gradient(135deg, rgba(89, 22, 14, 0.3), rgba(215, 96, 64, 0.12)),
    rgba(215, 175, 84, 0.12);
  box-shadow:
    inset 0 0 0 2px rgba(255, 119, 86, 0.4),
    0 0 18px rgba(255, 119, 86, 0.18);
}
.cell.interrupt-target::before {
  content: "可打断";
  position: absolute;
  right: 5px;
  top: 5px;
  z-index: 14;
  padding: 2px 6px;
  border: 1px solid rgba(255, 119, 86, 0.74);
  border-radius: 999px;
  background: rgba(35, 9, 6, 0.82);
  color: #ffcfbf;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.cell.aoe-victim .piece {
  box-shadow: inset 0 0 0 2px rgba(112, 167, 232, 0.7);
}
.cell.move { border-color: var(--jade); background: rgba(110, 216, 164, 0.11); }
.cell.move:active, .cell.selectable-target:active { transform: scale(0.97); }
.cell.focus { outline: 2px solid rgba(215, 175, 84, 0.7); }
.cell.flash-caster .piece { animation: casterFlash 0.42s ease-out; }
.cell.flash-target::after {
  content: "";
  position: absolute;
  inset: 10%;
  z-index: 5;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.72);
  pointer-events: none;
  animation: impactRing 0.46s ease-out forwards;
}
.cell.flash-martial::after { border-color: rgba(255, 153, 137, 0.9); }
.cell.flash-literary::after { border-color: rgba(245, 158, 11, 0.9); }
.cell.flash-heal::after { border-color: rgba(110, 216, 164, 0.92); }
.cell.flash-move::after { border-color: rgba(112, 167, 232, 0.92); }
.cell.flash-buff::after { border-color: rgba(215, 175, 84, 0.9); }
.cell.pending-martial { box-shadow: inset 0 0 0 1px rgba(228, 104, 86, 0.34); }
.cell.pending-literary { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.34); }
.cell.pending-heal { box-shadow: inset 0 0 0 1px rgba(110, 216, 164, 0.34); }
.cell.pending-move { box-shadow: inset 0 0 0 1px rgba(112, 167, 232, 0.34); }
.coord { position: absolute; left: 4px; top: 3px; color: #5f6654; font-size: 9px; }
.piece {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px;
  font-weight: 700;
  font-size: 11px;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.cell.selectable-target:hover .piece,
.cell.move:hover .piece { transform: scale(1.04); filter: brightness(1.16); }
.piece.ally { color: #b6f5d4; background: rgba(110, 216, 164, 0.15); }
.piece.enemy { color: #ffc1b8; background: rgba(228, 104, 86, 0.14); }
.piece-portrait {
  place-items: stretch;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(215, 175, 84, 0.36);
  border-radius: 9px;
  box-shadow:
    inset 0 0 0 1px rgba(35, 40, 29, 0.82),
    inset 0 -18px 28px rgba(0, 0, 0, 0.36);
}
.piece-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.piece-art-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
  filter: saturate(1.04) contrast(1.06);
}
.piece-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 8, 5, 0.04) 0%, rgba(6, 8, 5, 0.12) 42%, rgba(6, 8, 5, 0.58) 100%),
    linear-gradient(135deg, rgba(215, 175, 84, 0.12), transparent 28%, transparent 72%, rgba(215, 175, 84, 0.08));
}
.piece-label {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 10px;
  z-index: 1;
  padding: 2px 4px;
  border-radius: 8px;
  background: rgba(8, 10, 7, 0.72);
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.66);
}
.target-prediction {
  position: absolute;
  left: 50%;
  top: 13px;
  z-index: 12;
  transform: translateX(-50%);
  min-width: 86px;
  max-width: calc(100% - 8px);
  padding: 4px 6px;
  border: 1px solid rgba(215, 175, 84, 0.54);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 16, 8, 0.92), rgba(8, 10, 7, 0.9)),
    radial-gradient(circle at top, rgba(215, 175, 84, 0.18), transparent 70%);
  color: #f7dda0;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}
.piece-pending {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  animation: pendingCharge 1s linear infinite;
}
.piece-moving-source {
  opacity: 0;
  filter: saturate(0.8);
}
.piece-martial { background: linear-gradient(180deg, rgba(228, 104, 86, 0.2), rgba(228, 104, 86, 0.06)); }
.piece-literary { background: linear-gradient(180deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.06)); }
.piece-heal { background: linear-gradient(180deg, rgba(110, 216, 164, 0.22), rgba(110, 216, 164, 0.06)); }
.piece-move { background: linear-gradient(180deg, rgba(112, 167, 232, 0.22), rgba(112, 167, 232, 0.06)); }
.piece-low-ep::after {
  content: "";
  position: absolute;
  inset: 8% 6% 18%;
  border-radius: 14px;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.14), transparent 34%),
    linear-gradient(135deg, rgba(218, 236, 255, 0.14), rgba(92, 118, 148, 0.06));
  box-shadow:
    inset 0 0 0 1px rgba(214, 232, 255, 0.14),
    inset 0 -18px 30px rgba(7, 14, 24, 0.36);
  opacity: 0.9;
  pointer-events: none;
}
.piece-hp,
.piece-ep {
  position: absolute;
  left: 7px;
  right: 7px;
  height: 4px;
  background: #252b20;
  border-radius: 999px;
  overflow: hidden;
  z-index: 2;
}
.piece-hp { bottom: 10px; }
.piece-ep { bottom: 4px; background: rgba(24, 29, 35, 0.92); }
.piece-ep .fill.ep {
  background: linear-gradient(90deg, #7ba8ff, #d5e3ff);
  box-shadow: 0 0 10px rgba(126, 167, 255, 0.35);
}
.action-badge {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 18px;
  z-index: 7;
  display: grid;
  gap: 2px;
  padding: 4px 5px;
  border-radius: 8px;
  background: rgba(8, 10, 7, 0.9);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}
.action-badge strong { font-size: 10px; line-height: 1.1; color: #f3ead0; }
.action-kind, .action-time, .action-interrupt { font-size: 9px; line-height: 1; }
.action-kind { font-weight: 800; letter-spacing: 0.04em; }
.action-time { color: #d6e3ff; }
.action-interrupt { color: #b4baa8; }
.badge-martial { border-color: rgba(228, 104, 86, 0.36); }
.badge-literary { border-color: rgba(245, 158, 11, 0.36); }
.badge-heal { border-color: rgba(110, 216, 164, 0.36); }
.badge-move { border-color: rgba(112, 167, 232, 0.36); }
.pending-target-marker {
  position: absolute;
  right: 5px;
  top: calc(14px + var(--marker-offset, 0px));
  z-index: 6;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(8, 10, 7, 0.88);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.marker-martial { color: #ffb1a4; border-color: rgba(228, 104, 86, 0.42); }
.marker-literary { color: #ffd28a; border-color: rgba(245, 158, 11, 0.42); }
.marker-heal { color: #b8f6ce; border-color: rgba(110, 216, 164, 0.42); }
.marker-move { color: #bfdcff; border-color: rgba(112, 167, 232, 0.42); }
.boss-skill-callout {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--callout-offset, 0px));
  z-index: 18;
  display: grid;
  gap: 2px;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 196, 91, 0.78);
  border-radius: 8px;
  background: rgba(8, 10, 7, 0.92);
  color: #f7e7bc;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(255, 196, 91, 0.14), 0 12px 36px rgba(0, 0, 0, 0.36);
  animation: bossCalloutPulse 1.2s ease-in-out infinite;
}
.boss-skill-callout span,
.boss-skill-callout em {
  font-style: normal;
  font-size: 10px;
  color: #cfc6aa;
}
.boss-skill-callout strong {
  font-size: 15px;
  line-height: 1.15;
  color: #ffd073;
}
.boss-skill-callout b {
  color: #fff4d0;
}
.board-overlay {
  position: absolute;
  inset: 10px;
  z-index: 4;
  pointer-events: none;
}

.board-float-overlay {
  position: absolute;
  inset: 10px;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}

.board-portrait-overlay {
  position: absolute;
  inset: 10px;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.board-portrait {
  position: absolute;
  top: calc(50% + var(--portrait-offset, 0) * 18px);
  width: min(320px, 28vw);
  opacity: 0;
}

.board-portrait.portrait-round,
.board-portrait.portrait-stamina {
  width: min(348px, 30vw);
}

.board-portrait::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 12% 4% 4%;
  border-radius: 50%;
  opacity: 0;
  background:
    radial-gradient(ellipse at 50% 72%, rgba(229, 222, 190, 0.22), transparent 58%),
    radial-gradient(ellipse at 44% 56%, rgba(126, 139, 104, 0.18), transparent 62%);
  filter: blur(9px);
  animation: boardPortraitSmoke 1.8s ease-out forwards;
}

.board-portrait.ally {
  left: 0;
  transform-origin: left center;
}

.board-portrait.enemy {
  right: 0;
  transform-origin: right center;
}

.board-portrait img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  filter: saturate(1.02) contrast(1.02) drop-shadow(0 18px 40px rgba(0, 0, 0, 0.42));
}

.board-portrait.ally img { object-position: left center; }
.board-portrait.enemy img { object-position: right center; }
.pending-path {
  position: absolute;
  left: var(--path-x);
  top: var(--path-y);
  width: var(--path-length);
  height: 0;
  transform-origin: 0 0;
  transform: rotate(var(--path-angle));
}
.pending-trail {
  position: absolute;
  left: 0;
  top: -2px;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  opacity: 0.88;
}
.pending-ghost {
  position: absolute;
  left: calc(var(--path-progress, 0) * 100%);
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.24), 0 0 18px currentColor;
}
.pending-arrow {
  position: absolute;
  left: 100%;
  top: 0;
  width: 0;
  height: 0;
  transform: translate(-2px, -50%);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 14px solid rgba(144, 187, 255, 0.92);
  filter: drop-shadow(0 0 10px rgba(144, 187, 255, 0.38));
}
.pending-mover {
  position: absolute;
  left: calc(var(--path-visual-progress, 0) * 100%);
  top: 0;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(0,0,0,0.26), 0 0 0 1px rgba(255,255,255,0.16);
}
.pending-mover-art {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(25, 31, 44, 0.4), rgba(12, 15, 20, 0.82));
}
.pending-mover-art-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
  filter: saturate(1.06) contrast(1.08);
}
.pending-mover-label {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  z-index: 1;
  padding: 1px 2px;
  border-radius: 6px;
  background: rgba(8, 10, 7, 0.78);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  color: #f3ead0;
}
.mover-ally {
  border: 1px solid rgba(110, 216, 164, 0.48);
}
.mover-enemy {
  border: 1px solid rgba(228, 104, 86, 0.48);
}
.pending-travel-label {
  position: absolute;
  left: calc(var(--path-visual-progress, 0) * 100%);
  top: -14px;
  transform: translate(-50%, -50%);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(8, 10, 7, 0.88);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.path-martial .pending-trail,
.path-literary .pending-trail,
.path-heal .pending-trail {
  top: -3px;
  height: 6px;
  box-shadow: 0 0 16px rgba(255,255,255,0.12);
}
.path-martial .pending-trail { background: linear-gradient(90deg, rgba(228, 104, 86, 0.06), rgba(228, 104, 86, 0.92), rgba(255, 204, 188, 0.2)); }
.path-literary .pending-trail { background: linear-gradient(90deg, rgba(245, 158, 11, 0.06), rgba(245, 158, 11, 0.92), rgba(255, 216, 143, 0.2)); }
.path-heal .pending-trail { background: linear-gradient(90deg, rgba(110, 216, 164, 0.06), rgba(110, 216, 164, 0.9), rgba(192, 255, 218, 0.2)); }
.path-move .pending-trail {
  background: linear-gradient(90deg, rgba(112, 167, 232, 0.1), rgba(112, 167, 232, 0.82), rgba(200, 228, 255, 0.16));
  box-shadow: 0 0 12px rgba(112, 167, 232, 0.22);
}
.ghost-martial { color: #ff977f; background: rgba(228, 104, 86, 0.82); }
.ghost-literary { color: #f5b041; background: rgba(245, 158, 11, 0.82); }
.ghost-heal { color: #7be0a9; background: rgba(110, 216, 164, 0.82); }
.ghost-move { color: #90bbff; background: rgba(112, 167, 232, 0.82); }

@keyframes boardPortraitSettle {
  0% {
    opacity: 0;
  }
  14% {
    opacity: 0.96;
  }
  76% {
    opacity: 0.82;
  }
  100% {
    opacity: 0;
  }
}

@keyframes boardPortraitSmoke {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.82);
  }
  18% {
    opacity: 0.72;
  }
  78% {
    opacity: 0.34;
    transform: translateY(-16px) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) scale(1.18);
  }
}

.board-portrait.ally {
  animation-name: boardPortraitSettle, boardPortraitSlideLeft;
  animation-duration: 1.8s, 1.8s;
  animation-timing-function: cubic-bezier(0.2, 0.75, 0.18, 1), cubic-bezier(0.2, 0.75, 0.18, 1);
  animation-fill-mode: forwards, forwards;
}

.board-portrait.enemy {
  animation-name: boardPortraitSettle, boardPortraitSlideRight;
  animation-duration: 1.8s, 1.8s;
  animation-timing-function: cubic-bezier(0.2, 0.75, 0.18, 1), cubic-bezier(0.2, 0.75, 0.18, 1);
  animation-fill-mode: forwards, forwards;
}

@keyframes boardPortraitSlideLeft {
  0% {
    transform: translateX(-42px) scale(0.88);
  }
  18% {
    transform: translateX(0) scale(1.04);
  }
  100% {
    transform: translateX(0) scale(1.01);
  }
}

@keyframes boardPortraitSlideRight {
  0% {
    transform: translateX(42px) scale(0.88);
  }
  18% {
    transform: translateX(0) scale(1.04);
  }
  100% {
    transform: translateX(0) scale(1.01);
  }
}
.float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.float-text {
  position: absolute;
  left: 50%;
  top: var(--float-y, 50%);
  transform: translate(-50%, -50%) scale(var(--float-scale, 1));
  opacity: var(--float-opacity, 1);
  z-index: 8;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 10, 7, 0.88);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.board-float-text {
  left: var(--board-float-x);
  top: var(--board-float-y);
  transform: translate(calc(-50% + var(--board-float-drift, 0px)), calc(-50% - var(--board-float-rise, 12px))) scale(var(--float-scale, 1));
  font-size: 12px;
  padding: 4px 8px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
}
.float-text.martial { color: #ffb1a4; border-color: rgba(228, 104, 86, 0.42); }
.float-text.literary { color: #ffd28a; border-color: rgba(245, 158, 11, 0.42); }
.float-text.heal { color: #b8f6ce; border-color: rgba(110, 216, 164, 0.42); }
.float-text.resource { color: #b9d9ff; border-color: rgba(112, 167, 232, 0.42); }
.float-text.move { color: #bfdcff; border-color: rgba(112, 167, 232, 0.42); }
.float-text.status { color: #f4dd98; border-color: rgba(215, 175, 84, 0.42); }
.float-text.guard { color: #d8def1; border-color: rgba(185, 154, 241, 0.42); }

.board-reaction-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}
.reaction-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.reaction-ring {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(245, 158, 11, 0.9);
  background: radial-gradient(circle, rgba(245, 158, 11, 0.18), transparent 58%);
  transform: translate(-50%, -50%) scale(0.45);
  opacity: 0;
  animation: reactionRing 720ms ease-out forwards;
}
.reaction-ring.source { left: var(--rx1); top: var(--ry1); }
.reaction-ring.target { left: var(--rx2); top: var(--ry2); animation-delay: 80ms; }
.reaction-line {
  position: absolute;
  left: var(--rx1);
  top: var(--ry1);
  width: var(--reaction-length);
  height: 3px;
  border-radius: 999px;
  transform-origin: left center;
  transform: rotate(var(--reaction-angle)) scaleX(0);
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.95), rgba(255, 255, 255, 0.86), rgba(245, 158, 11, 0.95), transparent);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.36);
  animation: reactionLine 620ms cubic-bezier(0.2, 0.82, 0.2, 1) forwards;
}
.reaction-clashWin .reaction-ring,
.reaction-clashEven .reaction-ring,
.reaction-guarded .reaction-ring { border-color: rgba(244, 221, 152, 0.95); }
.reaction-clashLose .reaction-ring,
.reaction-guardBroken .reaction-ring { border-color: rgba(255, 112, 92, 0.95); }
.reaction-clashLose .reaction-line,
.reaction-guardBroken .reaction-line {
  background: linear-gradient(90deg, transparent, rgba(255, 112, 92, 0.96), rgba(255, 232, 208, 0.9), rgba(255, 112, 92, 0.96), transparent);
  box-shadow: 0 0 20px rgba(255, 112, 92, 0.36);
}

@keyframes reactionRing {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(0.82); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.45); }
}

@keyframes reactionLine {
  0% { opacity: 0; transform: rotate(var(--reaction-angle)) scaleX(0); }
  24% { opacity: 1; transform: rotate(var(--reaction-angle)) scaleX(0.55); }
  70% { opacity: 0.9; transform: rotate(var(--reaction-angle)) scaleX(1); }
  100% { opacity: 0; transform: rotate(var(--reaction-angle)) scaleX(1); }
}

@keyframes bossCalloutPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 196, 91, 0.14), 0 12px 36px rgba(0, 0, 0, 0.36); }
  50% { box-shadow: 0 0 0 3px rgba(255, 196, 91, 0.22), 0 16px 44px rgba(0, 0, 0, 0.42); }
}

.asset-preload-indicator {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 5px;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid rgba(117, 223, 201, 0.34);
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(8, 21, 20, 0.94), rgba(14, 15, 10, 0.9)),
    radial-gradient(circle at top right, rgba(117, 223, 201, 0.16), transparent 65%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.36);
  color: #d9fff3;
  font-size: 11px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}
.asset-preload-indicator strong {
  font-size: 12px;
  line-height: 1;
}
.asset-preload-indicator span {
  color: #a9cfc4;
}
.asset-preload-indicator i {
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(89, 108, 90, 0.38);
}
.asset-preload-indicator b {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #75dfc9, #f2d083);
  transition: width 160ms ease;
}
.asset-preload-indicator.complete {
  border-color: rgba(215, 175, 84, 0.32);
  color: #f4dd98;
}
.asset-preload-indicator.has-errors {
  border-color: rgba(255, 112, 92, 0.45);
}
.asset-preload-indicator.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.device-mobile .asset-preload-indicator {
  display: none;
}

.skill { text-align: left; width: 100%; transition: transform 0.1s ease, border-color 0.12s ease, background 0.12s ease; cursor: pointer; }
.skill:active:not(:disabled) { transform: translateY(1px); }
.skill.selected { border-color: var(--gold); background: rgba(215, 175, 84, 0.08); }
.skill.upgraded {
  border-color: rgba(110, 216, 164, 0.78);
  background: linear-gradient(135deg, rgba(110, 216, 164, 0.16), rgba(215, 175, 84, 0.08));
  box-shadow: 0 0 0 1px rgba(110, 216, 164, 0.16), 0 0 24px rgba(110, 216, 164, 0.12);
  animation: upgradePulse 1.4s ease-in-out infinite;
}
.reaction-ready {
  border-color: rgba(245, 158, 11, 0.72);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(228, 104, 86, 0.12));
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.22), 0 0 28px rgba(245, 158, 11, 0.16);
  animation: reactionPulse 0.9s ease-in-out infinite;
}
.skill .desc { margin-top: 5px; color: #d9d0b5; font-size: 11px; line-height: 1.45; }
.skill .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.skill-side {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 7px;
  min-width: 104px;
  text-align: right;
}
.cd-ring {
  --p: 0;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(42, 48, 36, 0.95) 0);
  color: #f5df9d;
  font-size: 10px;
  font-weight: 800;
}
.cd-ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: #11150e;
}
.cd-ring b {
  position: relative;
  z-index: 1;
}
.cd-ring.initial-ready {
  box-shadow: 0 0 0 2px rgba(215, 175, 84, 0.28);
}
.initial-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 1px 6px;
  border: 1px solid rgba(215, 175, 84, 0.45);
  border-radius: 999px;
  background: rgba(215, 175, 84, 0.12);
  color: #f5df9d;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}
.upgrade-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(110, 216, 164, 0.55);
  background: rgba(110, 216, 164, 0.14);
  color: #b6f5d4;
  font-size: 10px;
  font-weight: 900;
  vertical-align: middle;
}
.skill.planned { opacity: 0.62; }
.skill.has-variants { border-style: dashed; }
.skill-list {
  gap: 5px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.skill-list .skill {
  padding: 7px;
  border-radius: 10px;
}
.skill.compact-skill,
.variant-choice.compact-skill {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-height: 42px;
  padding: 7px 8px;
  text-align: left;
  border-color: rgba(88, 139, 139, 0.34);
  background:
    linear-gradient(135deg, rgba(16, 47, 50, 0.38), rgba(12, 20, 20, 0.84)),
    radial-gradient(circle at top right, rgba(92, 190, 176, 0.12), transparent 62%);
  box-shadow: inset 0 0 0 1px rgba(201, 244, 232, 0.03);
}
.skill.compact-skill .skill-name,
.variant-choice.compact-skill .skill-name {
  color: #d9fff3;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
}
.skill.compact-skill.selected,
.variant-choice.compact-skill.selected {
  border-color: rgba(117, 223, 201, 0.78);
  background:
    linear-gradient(135deg, rgba(29, 94, 89, 0.58), rgba(12, 27, 27, 0.9)),
    radial-gradient(circle at top right, rgba(149, 255, 230, 0.2), transparent 64%);
}
.skill-cd-slot {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
}
.prediction {
  margin-top: 6px;
  padding: 5px 7px;
  border: 1px solid rgba(215, 175, 84, 0.32);
  border-radius: 9px;
  color: #f3d58a;
  background: rgba(215, 175, 84, 0.08);
  font-size: 10px;
  line-height: 1.45;
}
.prediction.mini {
  border: 0;
  padding: 0;
  background: transparent;
  color: #f3d58a;
}
.variant-panel {
  grid-column: 1 / -1;
  border: 1px solid rgba(88, 139, 139, 0.36);
  border-radius: 12px;
  padding: 7px;
  background: rgba(12, 31, 32, 0.72);
}
.variant-grid {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 7px;
}
.variant-choice {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 8px;
  border-radius: 11px;
}
.variant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.variant-head > div {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.variant-head .initial-tag {
  margin-left: 0;
}
.variant-head .cd-ring {
  width: 26px;
  height: 26px;
}
.variant-choice.selected {
  border-color: rgba(117, 223, 201, 0.72);
  background: rgba(69, 156, 145, 0.18);
}
.variant-choice span {
  color: var(--muted);
  font-size: 10px;
}
.variant-choice em {
  color: #d9d0b5;
  font-size: 10px;
  font-style: normal;
  line-height: 1.45;
}

.board-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.global-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.global-actions button { min-width: 90px; padding: 7px 12px; }
.command-strip { padding: 11px 12px; }
.stamina-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
}
.stamina-bar .skill {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 6px;
}
.stamina-bar .skill .desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.extra-actions {
  margin-top: 10px;
  margin-bottom: 12px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(153, 123, 56, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(92, 64, 24, 0.18), rgba(24, 21, 13, 0.74)),
    radial-gradient(circle at top right, rgba(221, 173, 70, 0.14), transparent 54%);
  box-shadow: inset 0 0 0 1px rgba(255, 221, 150, 0.04);
}
.extra-actions.active {
  border-color: rgba(220, 176, 73, 0.74);
  background:
    linear-gradient(135deg, rgba(122, 79, 26, 0.34), rgba(28, 23, 12, 0.88)),
    radial-gradient(circle at top right, rgba(255, 205, 92, 0.32), transparent 58%);
  box-shadow:
    0 0 0 1px rgba(255, 214, 118, 0.12),
    0 0 22px rgba(204, 144, 43, 0.16);
}
.extra-actions .row h3 {
  color: #f0d289;
  letter-spacing: 0.06em;
}
.extra-actions.active .small {
  color: #ffe6ab;
}
.extra-action-bar .skill {
  min-width: 0;
  max-width: none;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.pager-btn {
  min-width: 72px;
  padding: 7px 10px;
  font-size: 11px;
}
.action-panel {
  max-height: calc(100vh - 86px);
  overflow: auto;
}

.log {
  max-height: 190px;
  overflow: auto;
  background: rgba(8, 10, 7, 0.82);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px;
}

.log-panel {
  min-height: 0;
}

.app.battle-started .log-panel {
  display: block;
  height: 104px;
  max-height: none;
  overflow: hidden;
  padding: 6px;
}

.app.battle-started .log {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.log-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  height: 100%;
  overflow: hidden;
}
.log-column {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 3px;
  padding: 5px 6px;
  border: 1px solid rgba(89, 108, 90, 0.28);
  border-radius: 9px;
  background: rgba(13, 17, 13, 0.7);
  min-height: 0;
  overflow: hidden;
}
.log-column > strong {
  color: #d8eacb;
  font-size: 11px;
  line-height: 1;
}
.log-stream {
  min-height: 0;
  overflow: auto;
}
.log-mobile-stream {
  display: none;
}
.log-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.log-tab {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
}
.log-tab.active {
  border-color: var(--gold);
  background: rgba(215, 175, 84, 0.14);
}
.entry { border-bottom: 1px solid #293023; padding: 0 0 4px; margin-bottom: 4px; font-size: 11px; line-height: 1.35; }
.entry:last-child { border-bottom: 0; }
.replay-panel {
  max-height: 360px;
  overflow: hidden;
}
.replay-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.replay-tab {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
}
.replay-tab.active {
  border-color: var(--jade);
  background: rgba(110, 216, 164, 0.12);
}
.replay-list {
  display: grid;
  gap: 7px;
  max-height: 290px;
  overflow: auto;
  margin-top: 10px;
  padding-right: 4px;
}
.replay-entry {
  padding: 8px 9px;
  border: 1px solid #2a3024;
  border-radius: 12px;
  background: rgba(9, 11, 8, 0.72);
}
.replay-entry.replay-damage { border-color: rgba(228, 104, 86, 0.26); }
.replay-entry.replay-status { border-color: rgba(215, 175, 84, 0.26); }
.replay-entry.replay-heal { border-color: rgba(110, 216, 164, 0.26); }
.replay-entry.replay-resource { border-color: rgba(112, 167, 232, 0.26); }
.replay-entry.replay-displace { border-color: rgba(185, 154, 241, 0.26); }
.replay-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.replay-head span {
  color: var(--muted);
  font-size: 11px;
}
.replay-body {
  margin-top: 4px;
  color: #ddd6bd;
  font-size: 12px;
  line-height: 1.45;
}
.settlement-panel {
  border-color: rgba(215, 175, 84, 0.42);
  background: linear-gradient(135deg, rgba(215, 175, 84, 0.08), rgba(18, 20, 16, 0.94));
}
.settlement-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.settlement-card {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border: 1px solid rgba(215, 175, 84, 0.24);
  border-radius: 14px;
  background: rgba(9, 11, 8, 0.7);
}
.settlement-card strong {
  color: var(--gold);
  font-size: 15px;
}
.settlement-card span {
  color: #f5e8bb;
  font-size: 18px;
  font-weight: 800;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  margin-right: 6px;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
}
.badge.ally { background: rgba(110, 216, 164, 0.15); border-color: rgba(110, 216, 164, 0.38); color: #b6f5d4; }
.badge.enemy { background: rgba(228, 104, 86, 0.16); border-color: rgba(228, 104, 86, 0.38); color: #ffc1b8; }
.num-dmg, .num-martial { color: #ff9989; font-weight: 700; font-size: 1.05em; font-variant-numeric: tabular-nums; }
.num-literary { color: var(--orange); font-weight: 700; font-size: 1.05em; font-variant-numeric: tabular-nums; }
.num-heal { color: #9ef2bf; font-weight: 700; font-size: 1.05em; font-variant-numeric: tabular-nums; }
.num-resource { color: #93c5fd; font-weight: 700; font-size: 1.05em; font-variant-numeric: tabular-nums; }
.formula { color: #d5d0bf; font-size: 12px; }

@keyframes targetPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(215, 175, 84, 0.28), 0 0 0 rgba(215, 175, 84, 0); }
  50% { box-shadow: inset 0 0 0 2px rgba(215, 175, 84, 0.72), 0 0 14px rgba(215, 175, 84, 0.3); }
}
@keyframes upgradePulse {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.35) brightness(1.08); }
}
@keyframes reactionPulse {
  0%, 100% { transform: translateY(0); filter: saturate(1) brightness(1); }
  50% { transform: translateY(-1px); filter: saturate(1.35) brightness(1.12); }
}
@keyframes casterFlash {
  0% { transform: scale(1); filter: brightness(1); }
  42% { transform: scale(1.07); filter: brightness(1.46); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes impactRing {
  0% { opacity: 0.9; transform: scale(0.26); }
  72% { opacity: 0.42; transform: scale(1.08); box-shadow: 0 0 16px currentColor; }
  100% { opacity: 0; transform: scale(1.36); box-shadow: 0 0 0 transparent; }
}
@keyframes pendingCharge {
  0% { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 0 0 0 rgba(255,255,255,0.02); }
  50% { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), 0 0 0 6px rgba(255,255,255,0.04); }
  100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 0 0 0 rgba(255,255,255,0.02); }
}
@keyframes portraitPreview {
  0% { opacity: 0; transform: translateY(18px) scale(0.94); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-2px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.setup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.ai-toggle-grid { grid-column: 1 / span 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ai-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #d9d0b5; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); transition: all 0.15s ease; }
.ai-toggle:has(input:checked) { border-color: var(--gold); background: rgba(215, 175, 84, 0.08); }
.ai-toggle input { margin: 0; }
.ai-toggle .ai-label { margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 4px; background: rgba(111, 125, 72, 0.2); color: var(--muted); }
.ai-toggle:has(input:checked) .ai-label { background: rgba(215, 175, 84, 0.2); color: var(--gold); }
.hidden { display: none !important; }

.log-tab, .replay-tab, .variant-choice, .cell.selectable-target, .cell.move {
  cursor: pointer;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #12150e;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: #4a503c;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6f7d48;
}

/* ========== Gallery 画廊 ========== */

.gallery-panel {
  overflow: visible;
}

.gallery-panel[open] {
  overflow: visible;
}

.gallery-body {
  padding: var(--panel-pad);
}

.gallery-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.gallery-tab {
  padding: 6px 16px;
  border-radius: var(--ui-control-radius);
  font-size: var(--ui-small-size);
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.gallery-tab:hover {
  color: var(--text);
  border-color: var(--line);
}

.gallery-tab.active {
  color: var(--gold);
  border-color: var(--line-strong);
  background: rgba(215, 175, 84, 0.08);
}

/* 立绘网格 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.gallery-card {
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.gallery-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.gallery-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #0a0b09;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.gallery-card:hover .gallery-card-img img {
  transform: scale(1.05);
}

.gallery-card-label {
  padding: 8px 10px;
  font-size: var(--ui-small-size);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 视频区布局 */
.gallery-video-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  min-height: 400px;
}

.gallery-video-sidebar {
  border-right: 1px solid var(--line);
  padding-right: 12px;
}

.gallery-video-school-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery-school-btn {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: var(--ui-small-size);
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.gallery-school-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.gallery-school-btn.active {
  color: var(--gold);
  border-color: var(--line-strong);
  background: rgba(215, 175, 84, 0.08);
}

.gallery-video-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gallery-video-player {
  width: 100%;
  min-height: 300px;
  background: #050604;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gallery-video-placeholder {
  color: var(--muted);
  font-size: var(--ui-small-size);
}

.gallery-video-now-playing {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  font-size: 11px;
  color: var(--gold);
  pointer-events: none;
}

.gallery-video-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-video-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--ui-small-size);
  transition: all 0.2s;
}

.gallery-video-item:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(215, 175, 84, 0.06);
}

.gallery-video-item-icon {
  font-size: 10px;
  color: var(--gold);
}

.gallery-video-empty {
  color: var(--muted);
  font-size: var(--ui-small-size);
  padding: 20px;
  text-align: center;
}

/* 大图预览模态 */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal.hidden {
  display: none !important;
}

.gallery-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.gallery-modal-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--ui-panel-radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.gallery-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  z-index: 2;
}

.gallery-modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.gallery-modal-imgs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.gallery-modal-img-group {
  text-align: center;
}

.gallery-modal-img-label {
  font-size: var(--ui-small-size);
  color: var(--muted);
  margin-bottom: 8px;
}

.gallery-modal-img-group img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.gallery-modal-info {
  text-align: center;
  margin-top: 14px;
  font-size: var(--ui-h3-size);
  color: var(--gold);
}

@media (max-width: 1180px) {
  .setup-env-grid,
  .setup-duel-grid { grid-template-columns: 1fr; }
  .setup-config-box {
    padding-right: var(--panel-pad);
  }
  .setup-launch-actions {
    justify-items: start;
    max-width: none;
    text-align: left;
  }
  .setup-portrait-splash {
    position: static;
    width: min(72vw, 280px);
    margin: 0 auto;
  }
  /* 浮动面板保持绝对定位，不变成 static */
  .compact-list { max-height: none; }
}

@media (max-width: 768px) {
  :root {
    --panel-pad: 14px;
    --panel-gap: 10px;
  }
  .app {
    padding: 12px;
    gap: 8px;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  #registryPanel,
  #logPanel,
  .timeline-float:not(.in-topbar),
  .team-float,
  .extra-float {
    display: none !important;
  }
  .setup-tree-row {
    grid-template-columns: 1fr;
  }
  .battle-stage {
    gap: 8px;
  }
  .board-panel {
    padding: 12px;
  }
  .battle-board-wrap {
    margin-top: 10px;
    padding-bottom: 6px;
  }
  .board {
    --board-min-width: 720px;
    gap: 4px;
    padding: 8px;
  }
  .board-panel .board {
    min-height: 620px;
  }
  .coord {
    display: none;
  }
  .piece {
    padding: 3px;
    font-size: 12px;
    line-height: 1.15;
  }
  .piece-label {
    bottom: 8px;
    font-size: 9px;
  }
  .pending-mover {
    width: 32px;
    height: 32px;
  }
  .focus-float,
  .ready-float,
  .turn-float {
    max-height: none;
    overflow: visible;
  }
  .selected-portrait.visible {
    opacity: 0.32;
  }
}

@media (max-width: 480px) {
  :root {
    --panel-pad: 12px;
    --panel-gap: 8px;
  }
  .app {
    padding: 10px;
  }
  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .setup-launch-actions {
    width: 100%;
  }
  .setup-portrait-splash {
    width: min(88vw, 240px);
  }
  .board {
    --board-min-width: 640px;
    gap: 3px;
    padding: 6px;
  }
  .board-panel .board {
    min-height: 540px;
  }
  .piece {
    padding: 2px;
    font-size: 10px;
  }
  .piece-label {
    bottom: 7px;
    font-size: 8px;
  }
  .piece-hp {
    left: 5px;
    right: 5px;
    bottom: 8px;
    height: 5px;
  }
  .piece-ep {
    left: 5px;
    right: 5px;
    bottom: 2px;
    height: 4px;
  }
  .pending-mover {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }
  .action-badge {
    left: 4px;
    right: 4px;
    bottom: 13px;
    padding: 3px 4px;
  }
  .mini-vitals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .selected-portrait.visible {
    opacity: 0.24;
  }
}

/* 角色拖拽样式 */
.piece {
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.piece[draggable="true"] {
  cursor: grab;
}

.piece[draggable="true"]:hover {
  box-shadow: 0 0 0 2px rgba(215, 175, 84, 0.5);
}

.piece.dragging {
  cursor: grabbing;
  opacity: 0.6;
}

/* 拖拽时的格子高亮 */
.cell.drag-over {
  background: rgba(110, 216, 164, 0.2);
  border-color: rgba(110, 216, 164, 0.5);
}

/* 手机端长按提示 */
@media (max-width: 768px) {
  .piece[draggable="true"]:active {
    transform: scale(0.95);
  }
}

/* 技能描述优化 */
.skill-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.skill-desc.expanded {
  -webkit-line-clamp: unset;
}

.skill-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 11px;
}

.skill-tag {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(215, 175, 84, 0.1);
  color: var(--gold);
  white-space: nowrap;
}

.skill-cost {
  color: var(--blue);
}

.skill-cooldown {
  color: var(--violet);
}

/* 技能卡片简化 */
.skill-card {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(18, 20, 16, 0.8);
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}

.skill-card:hover {
  border-color: rgba(215, 175, 84, 0.3);
  background: rgba(24, 26, 20, 0.9);
}

.skill-card.disabled {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.skill-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* 技能展开详情 */
.skill-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* UI清晰度优化 - 操作焦点 */
.turn-float {
  border: 2px solid rgba(215, 175, 84, 0.4);
  box-shadow: 0 0 20px rgba(215, 175, 84, 0.1);
}

.ready-float {
  border: 1px solid rgba(111, 125, 72, 0.3);
  opacity: 0.9;
}

.extra-float {
  border: 2px solid rgba(220, 176, 73, 0.6);
  background: linear-gradient(135deg, rgba(122, 79, 26, 0.2), rgba(28, 23, 12, 0.9));
}

.extra-float.active {
  border-color: rgba(220, 176, 73, 0.8);
  box-shadow: 0 0 20px rgba(220, 176, 73, 0.4);
}

/* 阶段提示条 */
#boardActionHint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(18, 20, 16, 0.95);
  border: 1px solid rgba(215, 175, 84, 0.3);
  color: var(--gold);
  font-size: 13px;
  font-weight: 500;
  z-index: 50;
  white-space: nowrap;
}

#boardActionHint[data-phase="ally-turn"] {
  border-color: rgba(110, 216, 164, 0.4);
  color: #b6f5d4;
}

#boardActionHint[data-phase="enemy-turn"] {
  border-color: rgba(228, 104, 86, 0.4);
  color: #ffc1b8;
}

#boardActionHint[data-phase="extra"] {
  border-color: rgba(220, 176, 73, 0.6);
  color: #f6df9e;
  animation: hintPulse 1.5s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 门派介绍样式 */
.setup-school-guide {
  margin-bottom: 12px;
}

.school-guide {
  padding: 12px;
  background: rgba(215, 175, 84, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(215, 175, 84, 0.15);
}

.school-guide-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.school-guide-header strong {
  font-size: 16px;
  color: var(--gold);
}

.school-tagline {
  font-size: 13px;
  color: var(--muted);
}

.school-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 10px;
}

.school-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.school-tip {
  padding: 4px 10px;
  background: rgba(110, 216, 164, 0.1);
  border-radius: 12px;
  font-size: 11px;
  color: #b6f5d4;
}

/* 木桩配置样式 */
.dummy-config {
  margin-top: 10px;
  padding: 10px;
  background: rgba(215, 175, 84, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(215, 175, 84, 0.15);
}

.dummy-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}

.dummy-toggle:last-child {
  margin-bottom: 0;
}

.dummy-toggle input {
  margin: 0;
}

@media (max-width: 768px) {
  /* 手机端回合外行动UI */
  .extra-float {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw !important;
    max-width: 400px;
    max-height: 70vh;
    z-index: 200;
    border-radius: 16px;
    background: rgba(18, 20, 16, 0.98);
    border: 2px solid rgba(220, 176, 73, 0.5);
  }

  .extra-float:not(.active) {
    display: none !important;
  }

  /* 遮罩层 */
  .extra-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
  }

  /* 关闭按钮 */
  .extra-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(228, 104, 86, 0.2);
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
  }
}

/* 战斗中隐藏标题 */
#topbarTitle.hidden {
  display: none;
}

/* 战斗中 topbar 变为 timeline 容器 */
.topbar.in-battle {
  padding: 8px 16px;
  gap: 8px;
  align-items: center;
}

.topbar.in-battle .topbar-timeline-host {
  display: block;
}

.topbar.in-battle .actions {
  flex-shrink: 0;
}

/* timeline 移到 topbar 内 */
.timeline-float.in-topbar {
  position: relative !important;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  transform: none !important;
  box-shadow: none !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.timeline-float.in-topbar .timeline-head {
  display: none;
}

.timeline-float.in-topbar .timeline {
  max-height: 56px;
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-float.in-topbar .global-actions {
  position: static;
  transform: none;
  margin-top: 0;
  flex-wrap: nowrap;
}

.topbar.in-battle .actions {
  gap: 6px;
}

.topbar.in-battle .actions button {
  padding: 9px 14px;
  min-width: 78px;
}

/* 手机端适配 */
@media (max-width: 768px) {
  .topbar.in-battle {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 10px;
  }
  
  .topbar.in-battle .topbar-timeline-host {
    width: 100%;
  }

  .topbar.in-battle .actions {
    gap: 4px;
  }
  
  .topbar.in-battle .actions button {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .timeline-float.in-topbar .timeline {
    max-height: 44px;
  }
  
  .timeline-float.in-topbar .global-actions {
    display: none;
  }
}
