* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(248, 74, 75, 0.12), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(85, 105, 255, 0.08), transparent 35%),
    #0b0d17;
  color: #e8eaef;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.header {
  margin-bottom: 20px;
}

.title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  color: #f3f4f6;
}

.subtitle {
  margin: 0;
  color: #8b92a5;
  font-size: 13px;
  line-height: 1.6;
}

.screen[hidden],
[hidden] {
  display: none !important;
}

.panel {
  padding: 18px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.hint {
  margin: 0 0 14px;
  color: #8b92a5;
  font-size: 13px;
  line-height: 1.55;
}

.step-label {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(248, 74, 75, 0.15);
  color: #ff8a8f;
  font-size: 11px;
  font-weight: 700;
}

.pick-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.pick-list--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.difficulty-section {
  margin-top: 4px;
  margin-bottom: 16px;
}

.difficulty-hint {
  margin-bottom: 10px;
}

.difficulty-category-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.difficulty-custom-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-stats-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.custom-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.custom-stat-label {
  min-width: 3em;
  font-weight: 600;
}

.custom-stat-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-stat-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.custom-stat-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.custom-stat-value {
  min-width: 5.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.custom-stat-step {
  margin-left: 4px;
  opacity: 0.65;
  font-size: 0.85em;
}

.difficulty-score-preview {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 193, 77, 0.25);
  background: rgba(255, 193, 77, 0.08);
}

.difficulty-score-line {
  margin: 0;
}

.difficulty-score-line + .difficulty-score-line {
  margin-top: 6px;
}

.difficulty-score-value {
  color: #ffc14d;
  font-size: 1.15em;
}

.battle-stats-score {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 193, 77, 0.1);
  border: 1px solid rgba(255, 193, 77, 0.22);
  text-align: center;
}

.enemy-screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.enemy-screen-main {
  min-width: 0;
}

.battle-leaderboard {
  padding: 14px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.02);
}

.battle-leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.battle-leaderboard-title {
  margin: 0;
  font-size: 15px;
}

.battle-leaderboard-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #8b92a5;
  font-size: 10px;
  font-weight: 700;
}

.battle-leaderboard-note {
  margin: 0 0 10px;
  color: #8b92a5;
  font-size: 11px;
  line-height: 1.5;
}

.battle-leaderboard-table-wrap {
  overflow-x: auto;
}

.battle-leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.battle-leaderboard-table th,
.battle-leaderboard-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.battle-leaderboard-table th {
  color: #8b92a5;
  font-weight: 600;
}

.battle-leaderboard-table .lb-rank {
  width: 1.8em;
  color: #8b92a5;
}

.battle-leaderboard-table .lb-score {
  font-variant-numeric: tabular-nums;
  color: #ffc14d;
}

.battle-leaderboard-section + .battle-leaderboard-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.battle-leaderboard-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #c4cad6;
}

.battle-leaderboard-empty {
  margin: 0;
  color: #8b92a5;
  font-size: 12px;
}

@media (max-width: 640px) {
  .enemy-screen-grid {
    grid-template-columns: 1fr;
  }

  .battle-leaderboard {
    order: -1;
  }
}

@media (max-width: 640px) {
  .difficulty-category-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .pick-list--compact {
    grid-template-columns: 1fr;
  }
}

.pick-card {
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pick-card--media {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.pick-card--trial {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border-color: rgba(120, 200, 255, 0.45);
  background: rgba(80, 160, 255, 0.08);
}

.pick-card--trial:hover {
  border-color: rgba(140, 220, 255, 0.65);
  background: rgba(80, 160, 255, 0.12);
}

.pick-card-media {
  flex: 0 0 auto;
}

.pick-card-text {
  flex: 1;
  min-width: 0;
}

.pick-card-img {
  display: block;
  object-fit: contain;
}

.pick-card-img.is-hero {
  width: 112px;
  height: 112px;
  border-radius: 10px;
  background: #000;
}

.pick-card-img.is-portrait {
  width: 72px;
  height: 108px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.pick-card:hover,
.pick-card.is-selected {
  border-color: rgba(248, 74, 75, 0.45);
  background: rgba(248, 74, 75, 0.08);
}

.pick-card-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pick-card-meta {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
}

.pick-card-desc {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #b8bfce;
  line-height: 1.5;
}

.equip-cost {
  margin-bottom: 12px;
  font-size: 13px;
  color: #c4cad6;
}

.equip-cost strong {
  color: #ff8a8f;
}

.equip-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.equip-party-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.equip-party-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 168px;
  padding: 10px 6px 8px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.equip-party-slot:hover:not(:disabled) {
  border-color: rgba(85, 105, 255, 0.45);
  background: rgba(85, 105, 255, 0.06);
}

.equip-party-slot.is-picking {
  border-color: rgba(125, 211, 160, 0.75);
  background: rgba(125, 211, 160, 0.1);
  box-shadow: 0 0 0 1px rgba(125, 211, 160, 0.35);
}

.equip-party-slot.is-empty {
  opacity: 0.45;
  cursor: default;
}

.equip-party-img {
  height: 108px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4));
}

.equip-party-name {
  font-size: 12px;
  font-weight: 800;
  color: #f3f4f6;
}

.equip-party-cost {
  font-size: 10px;
  color: #9ca3af;
}

.equip-party-cost strong {
  color: #ff8a8f;
}

.equip-party-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  width: 100%;
  min-height: 18px;
}

.equip-party-badge {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 700;
  color: #c4cad6;
  background: rgba(255, 255, 255, 0.08);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.equip-party-empty {
  font-size: 12px;
  color: #6b7280;
  font-weight: 700;
}

.equip-pick-hint {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
}

.equip-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.equip-pool-card {
  position: relative;
  min-width: 0;
}

.equip-pool-card.is-taken {
  opacity: 0.38;
  filter: grayscale(0.85);
}

.equip-pool-card.is-equipped-here .equip-pool-main {
  border-color: rgba(125, 211, 160, 0.7);
  background: rgba(125, 211, 160, 0.12);
}

.equip-pool-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 6px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.equip-pool-main:hover:not(:disabled) {
  border-color: rgba(85, 105, 255, 0.5);
  background: rgba(85, 105, 255, 0.1);
}

.equip-pool-main:disabled {
  cursor: not-allowed;
}

.equip-pool-media {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.equip-pool-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.equip-pool-img.is-missing {
  display: none;
}

.equip-chip-fallback {
  font-size: 18px;
  font-weight: 800;
  color: #c4cad6;
}

.equip-pool-name {
  font-size: 10px;
  font-weight: 700;
  color: #e8eaef;
  text-align: center;
  line-height: 1.2;
}

.equip-pool-cost {
  font-size: 9px;
  font-weight: 700;
  color: #fbbf24;
}

.equip-pool-info {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #c4cad6;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  cursor: pointer;
}

.equip-pool-info:hover {
  color: #fff;
  background: rgba(85, 105, 255, 0.75);
}

.equip-detail-popover {
  position: fixed;
  z-index: 120;
  width: min(220px, 84vw);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 14, 24, 0.96);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.equip-detail-popover-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 800;
  color: #f3f4f6;
}

.equip-detail-popover-meta {
  margin: 0 0 6px;
  font-size: 10px;
  color: #fbbf24;
  font-weight: 700;
}

.equip-detail-popover-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: #b8bfce;
}

.equip-detail-popover-media {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.equip-detail-popover-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #f3f4f6;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: rgba(248, 74, 75, 0.22);
  border-color: rgba(248, 74, 75, 0.45);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(248, 74, 75, 0.32);
}

.battle-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #9ca3af;
}

.battle-turn {
  font-weight: 700;
  color: #e8eaef;
}

.battle-phase.is-player {
  color: #7dd3a0;
}

.battle-phase.is-enemy {
  color: #fbbf24;
}

/* ── 战斗舞台：全宽卡片式角色 ── */
.battle-stage {
  margin-bottom: 10px;
}

.battle-action-dock {
  display: none;
  flex-shrink: 0;
  margin-bottom: 6px;
}

.battle-action-dock:not([hidden]) {
  display: block;
}

.battle-arena {
  position: relative;
  width: 100%;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 16px;
  --battle-player-sprite-h: 156px;
  --battle-boss-sprite-h: 170px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: visible;
  background:
    radial-gradient(circle at 50% 18%, rgba(248, 74, 75, 0.1), transparent 55%),
    radial-gradient(circle at 50% 82%, rgba(85, 105, 255, 0.1), transparent 50%),
    rgba(0, 0, 0, 0.22);
}

.battle-formation-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  align-items: end;
}

.is-enemy-row {
  flex-shrink: 0;
}

.is-party-row {
  flex-shrink: 0;
}

.battle-row-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-align: center;
  flex-shrink: 0;
}

.battle-row-label.is-party-label {
  color: #7dd3fc;
  margin-top: 2px;
}

.battle-enemy-slot,
.battle-party-slot {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.battle-slot--empty {
  min-height: 48px;
  width: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.battle-slot-label {
  font-size: 10px;
  color: #4b5563;
  font-weight: 700;
}

.battle-director-dock {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 22;
  width: auto;
  max-width: 58px;
  padding: 0;
  pointer-events: auto;
  background: transparent;
  border: none;
}

.btn-director-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: auto;
  min-width: 48px;
  padding: 5px 6px;
  font-size: 10px;
  line-height: 1.15;
  border-radius: 8px;
  border-color: rgba(253, 230, 138, 0.35);
  background: rgba(12, 14, 24, 0.9);
}

.btn-director-compact .director-dock-label {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-director-compact .director-dock-energy {
  font-size: 9px;
  color: #9ca3af;
}

.btn-director-compact .director-dock-energy strong {
  color: #fde68a;
  font-size: 11px;
}

.btn-director-compact::after {
  content: attr(data-cost);
  font-size: 8px;
  color: #6b7280;
  font-weight: 600;
}

.battle-popover-backdrop {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: default;
}

.battle-popover {
  position: absolute;
  z-index: 25;
  width: min(200px, 72vw);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 14, 24, 0.94);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(85, 105, 255, 0.2);
  pointer-events: auto;
  animation: popover-in 0.16s ease;
}

.battle-popover-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #f3f4f6;
}

.battle-popover-stats {
  font-size: 11px;
  color: #b8bfce;
  line-height: 1.55;
  margin-bottom: 8px;
}

.battle-popover-stats .detail-row {
  margin-bottom: 3px;
}

.battle-popover-stats strong {
  color: #e8eaef;
}

.battle-popover-tags {
  margin-bottom: 8px;
}

.battle-popover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.battle-popover-actions .btn {
  flex: 1 1 calc(33% - 6px);
  min-width: 52px;
  padding: 8px 6px;
  font-size: 12px;
}

.battle-popover-muted {
  margin: 0;
  font-size: 11px;
  color: #8b92a5;
}

.battle-popover.is-action-dock {
  position: static;
  width: 100%;
  max-width: none;
  padding: 12px 14px 14px;
  border-radius: 12px;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(85, 105, 255, 0.22);
  animation: popover-in-bottom 0.18s ease;
}

.battle-popover.is-action-dock .battle-popover-stats {
  margin-bottom: 10px;
}

.battle-popover.is-action-dock .battle-popover-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.battle-popover.is-action-dock .battle-popover-actions .btn {
  flex: none;
  min-width: 0;
  min-height: 44px;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 700;
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateX(-6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes popover-in-bottom {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.battle-actor.is-active .is-player-frame .battle-actor-sprite {
  outline: 2px solid rgba(85, 105, 255, 0.9);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 14px rgba(85, 105, 255, 0.35);
}

.battle-actor.is-active .is-player-frame {
  outline: none;
  box-shadow: none;
}

.unit-frame {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: none;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.is-enemy-frame {
  max-width: 100%;
  border-color: rgba(248, 74, 75, 0.35);
}

.is-boss-frame {
  border: none;
  background: transparent;
  overflow: visible;
}

.is-boss-frame .unit-frame-body {
  padding: 0;
  justify-content: center;
}

.is-boss-frame .battle-actor-sprite {
  display: inline-block;
  width: auto;
  max-width: 100%;
  line-height: 0;
}

.is-boss-frame .unit-frame-body .battle-actor-sprite {
  width: auto;
}

.is-boss-frame .unit-frame-footer {
  padding: 2px 0 0;
}

.stat-bar-fill.is-enemy-hp {
  background: linear-gradient(90deg, #dc2626, #f87171);
}

.enemy-core-diamonds {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 6;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}

.enemy-core-diamond {
  width: 11px;
  height: 11px;
  transform: rotate(45deg);
  border-radius: 2px;
  background: #4b5563;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.enemy-core-diamond.is-active {
  background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 45%, #991b1b 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 6px rgba(185, 28, 28, 0.55);
}

.enemy-core-diamond.is-spent {
  background: #4b5563;
  opacity: 0.85;
}

.is-minion-frame {
  max-width: 100%;
  border-color: rgba(248, 74, 75, 0.25);
}

.is-minion-frame .unit-frame-body {
  padding: 0;
  justify-content: center;
}

.is-minion-frame .battle-actor-sprite {
  display: inline-block;
  width: auto;
  max-width: 100%;
  line-height: 0;
}

.is-trial-mob .battle-sprite.is-enemy,
.is-training-dummy .battle-sprite.is-enemy {
  height: min(72px, 14vh);
}

.is-player-frame {
  max-width: 100%;
  border: none;
  background: transparent;
  overflow: visible;
}

.is-player-frame .unit-frame-body {
  padding: 0;
  justify-content: center;
}

.is-player-frame .battle-actor-sprite {
  display: inline-block;
  width: auto;
  max-width: 100%;
  line-height: 0;
}

.unit-portrait-bars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}

.is-player-frame .stat-bar {
  position: relative;
  height: 11px;
  margin: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.is-player-frame .stat-bar--hp {
  border-radius: 3px 3px 0 0;
}

.stat-bar {
  position: relative;
  height: 13px;
  margin: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.25s ease;
}

.stat-bar-fill.is-player-hp {
  background: linear-gradient(90deg, #16a34a, #4ade80);
}

.stat-bar-fill.is-player-skill {
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.stat-bar-label,
.unit-portrait-bars .unit-frame-hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  line-height: 1;
}

.unit-frame-header {
  padding: 4px 6px 2px;
  text-align: center;
}

.unit-frame-name {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-frame-body {
  display: flex;
  justify-content: center;
  padding: 0 4px;
}

.unit-frame-body .battle-actor-sprite {
  width: 100%;
}

.is-player-frame .unit-frame-body .battle-actor-sprite {
  width: auto;
}

.unit-frame-footer {
  padding: 4px 6px 6px;
}

.is-player-frame .unit-frame-footer {
  padding: 2px 0 0;
}

.unit-frame-hp-text,
.unit-frame-core-text {
  display: block;
  font-size: 10px;
  color: #b8bfce;
  margin-bottom: 3px;
  text-align: center;
}

.unit-frame-core {
  margin-top: 5px;
}

.unit-frame-tags {
  display: flex;
  flex-wrap: wrap;
  margin-top: 2px;
  justify-content: center;
  gap: 3px;
}

.battle-actor.is-enemy.is-active .unit-frame {
  outline: 2px solid rgba(253, 230, 138, 0.85);
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(253, 230, 138, 0.25);
}

.battle-director-bar {
  display: none;
}

.battle-actor {
  position: relative;
  z-index: 12;
  display: flex;
  justify-content: center;
  width: auto;
  flex-shrink: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.battle-actor.is-enemy {
  flex: 0 0 auto;
  align-items: center;
  padding-bottom: 0;
}

.battle-actor.is-player {
  flex: 0 0 auto;
  align-items: center;
}

.battle-sprite.is-enemy {
  height: min(100px, 20vh);
  width: auto;
}

.is-boss .battle-sprite.is-enemy {
  height: min(var(--battle-boss-sprite-h), 45vh);
}

.is-minion .battle-sprite.is-enemy,
.is-minion-frame .battle-sprite {
  height: min(52px, 10vh);
}

.battle-party-slot .battle-sprite.is-player,
.battle-party-slot .unit-frame-body .battle-sprite.is-player {
  height: min(var(--battle-player-sprite-h), 30vh);
  min-width: 88px;
  width: auto;
}

.battle-sprite.is-player {
  height: min(var(--battle-player-sprite-h), 30vh);
  min-width: 88px;
  width: auto;
}

.battle-actor.is-party-selectable {
  cursor: pointer;
}

.battle-actor.is-party-selectable .battle-actor-sprite {
  outline: 2px dashed rgba(125, 211, 160, 0.45);
  outline-offset: 2px;
  border-radius: 4px;
}

.battle-actor.is-party-selectable .unit-frame {
  outline: none;
}

.formation-count {
  margin: 0 0 12px;
  font-size: 13px;
  color: #c4cad6;
}

.formation-count strong {
  color: #ff8a8f;
}

.formation-pick-hint {
  margin: -6px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(125, 211, 160, 0.12);
  border: 1px solid rgba(125, 211, 160, 0.35);
  color: #7dd3a0;
  font-size: 13px;
  font-weight: 600;
}

.formation-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.formation-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 132px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.formation-slot.is-placeable {
  border-color: rgba(125, 211, 160, 0.55);
  background: rgba(125, 211, 160, 0.08);
}

.formation-slot:hover {
  border-color: rgba(248, 74, 75, 0.45);
}

.formation-slot-img {
  width: 64px;
  height: 96px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.formation-slot-name {
  font-size: 12px;
  font-weight: 700;
}

.formation-slot-empty {
  font-size: 22px;
  color: #6b7280;
  font-weight: 800;
}

.character-roster {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.character-roster-card {
  position: relative;
  min-width: 0;
}

.character-roster-card.is-selected .character-roster-tile {
  border-color: rgba(125, 211, 160, 0.75);
  box-shadow: 0 0 0 1px rgba(125, 211, 160, 0.35);
  background: rgba(125, 211, 160, 0.08);
}

.character-roster-card.is-on-field .character-roster-tile {
  opacity: 0.72;
}

.character-roster-card.is-on-field .character-roster-img {
  filter: saturate(0.75);
}

.character-roster-card.is-disabled .character-roster-tile {
  opacity: 0.38;
  cursor: not-allowed;
}

.character-roster-card.is-disabled .character-roster-img {
  filter: grayscale(0.85);
}

.character-roster-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 5px 4px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.character-roster-tile:hover {
  border-color: rgba(248, 74, 75, 0.45);
  background: rgba(255, 255, 255, 0.05);
}

.character-roster-card.is-on-field .character-roster-tile {
  cursor: default;
}

.character-roster-img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  object-position: center bottom;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}

.character-roster-name {
  width: 100%;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-roster-info {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(12, 14, 24, 0.9);
  color: #c4cad6;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.character-roster-info:hover {
  color: #fff;
  border-color: rgba(85, 105, 255, 0.55);
  background: rgba(85, 105, 255, 0.75);
}

.character-detail-popover {
  pointer-events: auto;
  width: min(340px, calc(100vw - 24px));
  max-height: min(52vh, 360px);
  overflow-y: auto;
  padding-top: 28px;
}

.character-detail-popover.is-dock {
  position: fixed;
  left: 12px !important;
  right: 12px !important;
  bottom: 12px !important;
  top: auto !important;
  width: auto !important;
  max-width: none;
  max-height: min(38vh, 280px);
  border-radius: 14px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

.character-detail-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #c4cad6;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.character-detail-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.director-pick-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.director-pick-heading {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 800;
  color: #f3f4f6;
}

.director-pick-hint {
  margin: 0 0 10px;
}

.director-pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}

.director-pick-card {
  position: relative;
}

.director-pick-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  padding: 10px 28px 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.director-pick-main:hover {
  border-color: rgba(248, 74, 75, 0.45);
}

.director-pick-card.is-selected .director-pick-main {
  border-color: rgba(248, 74, 75, 0.85);
  background: rgba(248, 74, 75, 0.12);
}

.director-pick-main .pick-card-title {
  font-size: 13px;
  font-weight: 800;
}

.director-pick-main .pick-card-meta {
  font-size: 10px;
  color: #fbbf24;
  font-weight: 700;
}

.director-pick-info {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #c4cad6;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  cursor: pointer;
}

.director-pick-info:hover {
  color: #fff;
  background: rgba(85, 105, 255, 0.75);
}

.director-detail-extra {
  margin-top: 8px;
  color: #8b93a7;
}

.battle-actor-sprite {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: flex-end;
  max-width: 100%;
  vertical-align: bottom;
}

.battle-sprite {
  display: block;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.5));
}

.battle-hit-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.battle-hit-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 45, 45, 0.72);
  mix-blend-mode: screen;
  opacity: 0;
}

.battle-hit-slash {
  position: absolute;
  top: 18%;
  left: -20%;
  width: 140%;
  height: 42%;
  opacity: 0;
  transform: rotate(-28deg);
}

.battle-hit-slash::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  margin-top: -2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 18%,
    #fff 42%,
    #ff6b6b 58%,
    rgba(255, 80, 80, 0.2) 82%,
    transparent 100%
  );
  box-shadow:
    0 0 10px rgba(255, 255, 255, 0.95),
    0 0 22px rgba(255, 70, 70, 0.85),
    0 0 36px rgba(255, 40, 40, 0.45);
}

.battle-hit-slash.is-slash-2 {
  top: 42%;
  transform: rotate(-22deg);
}

.battle-hit-slash.is-slash-2::before {
  height: 3px;
  margin-top: -1.5px;
  opacity: 0.85;
}

.battle-actor.is-hit {
  animation: actor-hit-shake 0.42s ease;
}

.battle-actor.is-hit .battle-sprite {
  animation: sprite-hit-tint 0.42s ease;
}

.battle-actor.is-hit .battle-hit-flash {
  animation: hit-red-overlay 0.42s ease;
}

.battle-actor.is-hit .battle-hit-slash {
  animation: slash-cut 0.38s ease-out;
}

.battle-actor.is-hit .battle-hit-slash.is-slash-2 {
  animation: slash-cut-alt 0.38s ease-out 0.06s;
}

@keyframes slash-cut-alt {
  0% {
    opacity: 0;
    transform: rotate(-22deg) scaleX(0.1) translateX(-10%);
  }
  20% {
    opacity: 0.9;
    transform: rotate(-22deg) scaleX(1) translateX(0);
  }
  100% {
    opacity: 0;
    transform: rotate(-22deg) scaleX(1.1) translateX(8%);
  }
}

@keyframes actor-hit-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-7px);
  }
  36% {
    transform: translateX(6px);
  }
  54% {
    transform: translateX(-4px);
  }
  72% {
    transform: translateX(2px);
  }
}

@keyframes sprite-hit-tint {
  0%,
  100% {
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.5));
  }
  12% {
    filter: drop-shadow(0 0 28px rgba(255, 60, 60, 1)) brightness(2.2) saturate(2.5)
      hue-rotate(-18deg);
  }
  28% {
    filter: drop-shadow(0 0 16px rgba(255, 90, 90, 0.7)) brightness(1.35) saturate(1.4);
  }
}

@keyframes hit-red-overlay {
  0%,
  100% {
    opacity: 0;
  }
  10% {
    opacity: 0.95;
  }
  35% {
    opacity: 0.55;
  }
  60% {
    opacity: 0.15;
  }
}

@keyframes slash-cut {
  0% {
    opacity: 0;
    transform: rotate(-28deg) scaleX(0.15) translateX(-12%);
  }
  18% {
    opacity: 1;
    transform: rotate(-28deg) scaleX(1) translateX(0);
  }
  100% {
    opacity: 0;
    transform: rotate(-28deg) scaleX(1.15) translateX(6%);
  }
}

.battle-actor.is-targetable {
  cursor: pointer;
}

.battle-actor.is-targetable .battle-actor-sprite::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 12px;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.battle-actor.is-targetable:hover .battle-actor-sprite::after,
.battle-actor.is-targetable.is-pending .battle-actor-sprite::after {
  border-color: rgba(248, 74, 75, 0.75);
  box-shadow: 0 0 20px rgba(248, 74, 75, 0.35);
}

.battle-actor.is-acting .unit-frame {
  animation: enemy-acting-pulse 0.72s ease-in-out infinite;
  box-shadow: 0 0 0 2px rgba(255, 180, 80, 0.85), 0 0 24px rgba(255, 150, 60, 0.45);
}

@keyframes enemy-acting-pulse {
  0%,
  100% {
    transform: translateY(0);
    filter: brightness(1);
  }
  50% {
    transform: translateY(-3px);
    filter: brightness(1.12);
  }
}

.battle-actor.is-dead {
  opacity: 0.25;
  pointer-events: none;
}

.battle-defeat-mark {
  display: none;
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  font-size: clamp(36px, 10vw, 56px);
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.75));
  pointer-events: none;
  z-index: 7;
}

.battle-actor.is-defeated .battle-sprite {
  opacity: 0.2;
  filter: grayscale(1) brightness(0.55) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.65));
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.battle-actor.is-defeated .battle-defeat-mark {
  display: block;
  animation: defeat-mark-pop 0.42s ease-out forwards;
}

@keyframes defeat-mark-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(-18deg);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -58%) scale(1.12) rotate(6deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -62%) scale(1) rotate(0deg);
  }
}

.battle-actor.is-defeated {
  pointer-events: none;
}

.battle-imprison-fx {
  position: absolute;
  inset: -4px -8px -6px;
  pointer-events: none;
  z-index: 8;
  display: none;
}

.battle-actor.is-imprisoned .battle-imprison-fx {
  display: block;
}

.battle-actor.is-imprisoned .battle-sprite.is-player {
  filter: grayscale(0.35) brightness(0.72) drop-shadow(0 0 10px rgba(120, 160, 255, 0.45));
}

.battle-chain {
  position: absolute;
  font-size: 22px;
  line-height: 1;
  color: #c4b5fd;
  filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.85));
  animation: battle-chain-pulse 1.2s ease-in-out infinite;
}

.battle-chain--left {
  left: 2%;
  top: 18%;
  transform: rotate(-28deg);
}

.battle-chain--right {
  right: 2%;
  top: 52%;
  transform: rotate(24deg);
  animation-delay: 0.35s;
}

.battle-chain-lock {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  opacity: 0.92;
  filter: drop-shadow(0 0 8px rgba(147, 197, 253, 0.9));
}

@keyframes battle-chain-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: translateY(0) rotate(-28deg);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px) rotate(-22deg);
  }
}

.battle-chain--right {
  animation-name: battle-chain-pulse-right;
}

@keyframes battle-chain-pulse-right {
  0%,
  100% {
    opacity: 0.55;
    transform: translateY(0) rotate(24deg);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px) rotate(30deg);
  }
}

.battle-actor.is-defeated.is-hit .battle-sprite {
  animation: sprite-hit-tint 0.42s ease;
}

.battle-chickens {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 0;
}

.battle-chickens .unit-card {
  min-width: 100px;
  max-width: 140px;
  padding: 10px;
}

.battle-side {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px;
}

.battle-stat-panel {
  padding: 12px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.battle-stat-panel.is-enemy-panel {
  border-color: rgba(248, 74, 75, 0.22);
}

.battle-stat-panel.is-player-panel {
  border-color: rgba(85, 105, 255, 0.28);
}

.battle-stat-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.battle-side-extra {
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.field {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.field-enemy {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.unit-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.unit-card.is-targetable {
  cursor: pointer;
}

.unit-card.is-targetable:hover,
.unit-card.is-targetable.is-pending {
  border-color: rgba(248, 74, 75, 0.55);
  box-shadow: 0 0 0 1px rgba(248, 74, 75, 0.25);
}

.unit-card.is-dead {
  opacity: 0.35;
}

.unit-card.is-player {
  border-color: rgba(85, 105, 255, 0.35);
  background: rgba(85, 105, 255, 0.08);
}

.unit-card.is-hit {
  animation: unit-hit-flash 0.48s ease;
}

@keyframes unit-hit-flash {
  0% {
    box-shadow: none;
    filter: none;
  }
  25% {
    box-shadow: 0 0 0 2px rgba(248, 74, 75, 0.75), 0 0 18px rgba(248, 74, 75, 0.45);
    filter: brightness(1.35);
    background-color: rgba(248, 74, 75, 0.28);
  }
  100% {
    box-shadow: none;
    filter: none;
  }
}

.unit-card-layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.unit-portrait-wrap {
  flex: 0 0 auto;
}

.unit-card-main {
  flex: 1;
  min-width: 0;
}

.unit-portrait {
  display: block;
  object-fit: contain;
}

.unit-portrait.is-icon {
  width: 56px;
  height: 56px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.unit-portrait.is-portrait {
  width: 64px;
  height: 96px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.unit-name {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.unit-stats {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #b8bfce;
}

.hp-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f84a4b, #ff7b7c);
  transition: width 0.25s ease;
}

.hp-bar-fill.is-player {
  background: linear-gradient(90deg, #5569ff, #7b8cff);
}

.core-wrap {
  margin-top: 8px;
}

.core-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.core-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.core-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fbbf24, #fde68a);
  transition: width 0.25s ease;
}

.core-bar-fill.is-broken {
  background: rgba(255, 255, 255, 0.15);
  width: 0 !important;
}

.unit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: #c4cad6;
}

.tag-warn {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.tag-buff {
  background: rgba(125, 211, 160, 0.15);
  color: #7dd3a0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.battle-director-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.battle-director-title {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.battle-director-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.battle-director-energy {
  font-size: 12px;
  color: #b8bfce;
}

.battle-director-energy strong {
  color: #fde68a;
}

.director-actions {
  margin-bottom: 14px;
}

.btn-director {
  background: rgba(253, 230, 138, 0.12);
  border-color: rgba(253, 230, 138, 0.35);
}

.btn-director:hover:not(:disabled) {
  background: rgba(253, 230, 138, 0.2);
}

.action-hint {
  width: 100%;
  margin: 0 0 4px;
  font-size: 12px;
  color: #8b92a5;
}

.battle-actor.is-director-targetable {
  cursor: pointer;
}

.battle-actor.is-director-targetable .battle-actor-sprite::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 12px;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.battle-actor.is-director-targetable:hover .battle-actor-sprite::after,
.battle-actor.is-director-targetable.is-director-pending .battle-actor-sprite::after {
  border-color: rgba(253, 230, 138, 0.85);
  box-shadow: 0 0 20px rgba(253, 230, 138, 0.35);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  font-size: 11px;
  color: #9ca3af;
}

.status-grid strong {
  color: #e8eaef;
}

.log {
  max-height: 220px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  line-height: 1.55;
}

.log-entry-wrap {
  margin-bottom: 6px;
}

.log-entry {
  margin-bottom: 0;
  color: #b8bfce;
}

.log-entry-formula {
  margin: 2px 0 0 10px;
  font-size: 10px;
  line-height: 1.45;
  color: #7a8294;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  word-break: break-word;
}

.log-entry-wrap .log-entry.crit {
  color: #fbbf24;
}

.log-entry-wrap .log-entry.damage {
  color: #fca5a5;
}

.log-entry-wrap .log-entry.buff {
  color: #7dd3a0;
}

.log-entry-wrap .log-entry.debuff {
  color: #c4b5fd;
}

.log-entry-wrap .log-entry.enemy {
  color: #93c5fd;
}

.log-entry-wrap .log-entry.win {
  color: #7dd3a0;
  font-weight: 700;
}

.log-entry-wrap .log-entry.lose {
  color: #f87171;
  font-weight: 700;
}

.end-banner {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.end-banner.win {
  background: rgba(125, 211, 160, 0.12);
  border: 1px solid rgba(125, 211, 160, 0.35);
  color: #7dd3a0;
}

.end-banner.lose {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #f87171;
}

.battle-stats-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 10, 16, 0.72);
}

.battle-stats-modal[hidden] {
  display: none;
}

.battle-stats-dialog {
  width: min(100%, 480px);
  max-height: min(80vh, 520px);
  overflow: auto;
}

.battle-stats-title {
  margin: 0 0 12px;
  font-size: 18px;
  text-align: center;
}

.battle-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 14px;
}

.battle-stats-table th,
.battle-stats-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.battle-stats-table th:first-child,
.battle-stats-table td:first-child {
  text-align: left;
}

.battle-stats-table thead th {
  color: #8b92a5;
  font-weight: 600;
}

.battle-stats-table tbody tr:last-child td {
  border-bottom: none;
}

.battle-stats-total td {
  font-weight: 700;
  color: #c4cad6;
}

#btn-battle-stats-close {
  width: 100%;
}

.actions.panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions.panel .action-hint {
  flex: 1 1 100%;
}

.enemy-core-diamond.is-pending {
  background: rgba(120, 130, 150, 0.35);
  border-color: rgba(140, 150, 170, 0.5);
  box-shadow: none;
}

.battle-plane-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.battle-arena.is-plane-shake {
  animation: battle-plane-shake 0.55s ease-out;
}

@keyframes battle-plane-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-4px, 2px);
  }
  40% {
    transform: translate(5px, -3px);
  }
  60% {
    transform: translate(-3px, -2px);
  }
  80% {
    transform: translate(4px, 1px);
  }
}

.battle-plane-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 40%,
    rgba(255, 120, 60, 0.55),
    rgba(255, 40, 40, 0.25) 45%,
    transparent 70%
  );
  opacity: 0;
  animation: battle-plane-flash 0.65s ease-out forwards;
}

@keyframes battle-plane-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.battle-plane-trail {
  position: absolute;
  left: -20%;
  top: 5%;
  width: 140%;
  height: 42%;
  background: linear-gradient(
    125deg,
    transparent 0%,
    transparent 38%,
    rgba(255, 255, 255, 0.15) 44%,
    rgba(255, 200, 80, 0.85) 50%,
    rgba(255, 80, 40, 0.7) 54%,
    transparent 60%,
    transparent 100%
  );
  opacity: 0;
  transform: rotate(8deg);
  animation: battle-plane-trail 0.75s ease-out forwards;
}

@keyframes battle-plane-trail {
  0% {
    opacity: 0;
    transform: rotate(8deg) translateX(30%);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(8deg) translateX(-25%);
  }
}

.battle-plane-boom {
  position: absolute;
  left: 18%;
  top: 48%;
  width: 64%;
  height: 38%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 200, 0.95) 0%,
    rgba(255, 120, 40, 0.75) 28%,
    rgba(255, 40, 20, 0.35) 55%,
    transparent 72%
  );
  opacity: 0;
  transform: scale(0.4);
  animation: battle-plane-boom 0.7s ease-out 0.32s forwards;
}

@keyframes battle-plane-boom {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  25% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

.battle-plane-strike {
  position: absolute;
  font-size: 56px;
  line-height: 1;
  color: #fff8e8;
  filter: drop-shadow(0 0 12px rgba(255, 180, 60, 0.95))
    drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
  animation: battle-plane-sweep 0.95s ease-in forwards;
  opacity: 0;
}

.battle-plane-strike.is-delayed {
  font-size: 44px;
  color: #ffe4b5;
  animation: battle-plane-sweep-2 1s ease-in 0.18s forwards;
}

@keyframes battle-plane-sweep {
  0% {
    left: 92%;
    top: 4%;
    opacity: 0;
    transform: rotate(118deg) scale(0.65);
  }
  12% {
    opacity: 1;
  }
  100% {
    left: 2%;
    top: 78%;
    opacity: 0;
    transform: rotate(118deg) scale(1.25);
  }
}

@keyframes battle-plane-sweep-2 {
  0% {
    left: 88%;
    top: 18%;
    opacity: 0;
    transform: rotate(132deg) scale(0.6);
  }
  15% {
    opacity: 0.9;
  }
  100% {
    left: 6%;
    top: 85%;
    opacity: 0;
    transform: rotate(132deg) scale(1.05);
  }
}

.is-party-row.is-plane-hit {
  filter: brightness(1.35) saturate(1.2);
  transition: filter 0.15s ease;
}

.battle-actor.is-fighter .unit-frame-name {
  color: #9bb4d4;
}

.back-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: #8b92a5;
  text-decoration: none;
}

.back-link:hover {
  color: #c4cad6;
}

.battle-float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 6;
}

.battle-float-layer.is-card {
  inset: auto;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
}

.battle-float-num {
  position: absolute;
  left: 50%;
  top: 32%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 900;
  color: #ff6b6b;
  text-shadow:
    0 0 8px rgba(0, 0, 0, 0.9),
    0 2px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  animation: battle-float-up 0.95s ease-out forwards;
  pointer-events: none;
}

.battle-float-num.is-heal {
  color: #7dd3a0;
}

.battle-float-num.is-core {
  color: #fbbf24;
  font-size: 20px;
}

.battle-float-num.is-crit {
  color: #fde047;
  font-size: 26px;
}

@keyframes battle-float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.85);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -52px) scale(1);
  }
}

.battle-chickens .unit-card {
  position: relative;
}

/* ── 战斗屏：手机一屏内（立绘 + 信息 + 技能）── */
.battle-screen {
  display: flex;
  flex-direction: column;
}

@media (max-width: 640px) {
  body:has(.battle-screen:not([hidden])) .page {
    padding: 8px 8px 10px;
    max-width: none;
  }

  body:has(.battle-screen:not([hidden])) .header {
    display: none;
  }

  .battle-screen {
    min-height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .battle-top {
    margin-bottom: 6px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .battle-stage {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 4px;
    overflow-y: auto;
  }

  .battle-action-dock:not([hidden]) {
    margin-bottom: 4px;
  }

  .battle-screen.is-popover-open .action-hint {
    display: none;
  }

  .battle-arena {
    min-height: min(360px, 58dvh);
    flex: 0 0 auto;
    padding: 8px 6px 12px;
    gap: 10px;
    --battle-player-sprite-h: 108px;
    --battle-boss-sprite-h: 112px;
  }

  .is-party-row {
    min-height: 120px;
  }

  .battle-director-dock {
    right: 4px;
    max-width: 52px;
  }

  .btn-director-compact {
    min-width: 44px;
    padding: 4px 5px;
  }

  .is-boss .battle-sprite.is-enemy {
    height: min(var(--battle-boss-sprite-h), 32dvh);
  }

  .is-minion .battle-sprite.is-enemy {
    height: min(44px, 9dvh);
  }

  .battle-party-slot .battle-sprite.is-player,
  .battle-party-slot .unit-frame-body .battle-sprite.is-player {
    height: min(var(--battle-player-sprite-h), 28dvh);
    min-width: 72px;
  }

  .equip-party-img {
    height: 88px;
  }

  .equip-party-slot {
    min-height: 140px;
    padding: 8px 4px 6px;
  }

  .equip-pool {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .equip-pool-media {
    width: 44px;
    height: 44px;
  }

  .battle-slot--empty {
    min-height: 36px;
  }

  .unit-frame-name {
    font-size: 11px;
  }

  .unit-frame-hp-text,
  .unit-frame-core-text {
    font-size: 9px;
  }

  .unit-frame-detail-inner {
    font-size: 10px;
  }

  .battle-director-bar {
    margin-bottom: 6px;
    padding: 8px 10px;
    gap: 4px 10px;
  }

  .actions,
  .director-actions {
    flex-shrink: 0;
    padding: 8px 10px;
    margin-bottom: 6px;
  }

  .actions {
    gap: 6px;
  }

  .actions .btn,
  .director-actions .btn {
    padding: 7px 9px;
    font-size: 12px;
    border-radius: 8px;
  }

  .action-hint {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .log {
    flex-shrink: 0;
    max-height: 64px;
    padding: 6px 8px;
    font-size: 10px;
    line-height: 1.45;
    margin-bottom: 0;
  }

  .end-banner {
    margin-bottom: 6px;
    padding: 10px;
    font-size: 15px;
    flex-shrink: 0;
  }

  .battle-float-num {
    font-size: 18px;
  }

  .battle-float-num.is-crit {
    font-size: 21px;
  }
}
