/* 戦闘パネル、戦闘ゲージ、武器/戦士アニメーション用のスタイル。 */

/* 透明化は表示専用。特殊操作への祖先と、それ以外の枝を分けて隠す。 */
#app #battlePanel.battle-visibility-dimmed,
#app #battlePanel.battle-visibility-dimmed * {
  pointer-events: none !important;
}
#app #battlePanel.battle-visibility-dimmed .battle-visibility-exception,
#app #battlePanel.battle-visibility-dimmed .battle-visibility-exception *,
#app #battlePanel.battle-visibility-dimmed.battle-visibility-exception,
#app #battlePanel.battle-visibility-dimmed.battle-visibility-exception * {
  pointer-events: auto !important;
}
#app #battlePanel .battle-visibility-muted {
  opacity: 0 !important;
}
#app #battlePanel .battle-visibility-path,
#app #battlePanel.battle-visibility-path {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  /* 透明な枠でも背景ぼかしは残るため、最小化中は合成効果も外す。 */
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  isolation: isolate;
}
#app #battlePanel .battle-visibility-static-path,
#app #battlePanel.battle-visibility-static-path {
  position: relative;
}
#app #battlePanel .battle-visibility-path::before,
#app #battlePanel .battle-visibility-path::after,
#app #battlePanel.battle-visibility-path::before,
#app #battlePanel.battle-visibility-path::after {
  opacity: 0 !important;
}
#app #battlePanel [data-battle-visibility-paint] {
  position: absolute;
  z-index: -1;
  inset: 0;
  display: block;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none !important;
}
body > .battle-visibility-toggle {
  --battle-visibility-mark-inset: 0px;
  position: fixed;
  /* 縦画面の通知（90）の下で、戦闘本体（80）より上に置く。 */
  z-index: 89;
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #f3e7be;
  font: 0/0 system-ui, sans-serif;
  opacity: 1;
  touch-action: manipulation;
}
/* 効果の選択はミニ詳細との間隔が狭いため、見えるボタンの余白を保つ。 */
body:has(#battlePanel:is([data-mode="card-inspection"], [data-mode="unit-target-choice"])) > .battle-visibility-toggle {
  --battle-visibility-mark-inset: 4px;
}
body > .battle-visibility-toggle::before {
  position: absolute;
  z-index: -1;
  /* タップ領域の左上へ見えるボタンを寄せる。 */
  inset: var(--battle-visibility-mark-inset) calc(8px - var(--battle-visibility-mark-inset))
    calc(8px - var(--battle-visibility-mark-inset)) var(--battle-visibility-mark-inset);
  border: 1px solid #b5a273aa;
  border-radius: 6px;
  background: #172c25f5;
  content: "";
}
/* 字体のベースラインに依存せず、記号をボタンの表示部分の中心へ置く。 */
body > .battle-visibility-toggle::after {
  position: absolute;
  top: calc(12px + var(--battle-visibility-mark-inset));
  left: calc(12px + var(--battle-visibility-mark-inset));
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  background: linear-gradient(currentColor, currentColor) center / 12px 2px no-repeat;
  content: "";
  pointer-events: none;
}
body > .battle-visibility-toggle[aria-pressed="true"]::after {
  background:
    linear-gradient(currentColor, currentColor) center / 12px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 12px no-repeat;
}
body > .battle-visibility-toggle[hidden] { display: none; }
body > .battle-visibility-toggle:focus-visible { outline: 2px solid #ffe19a; outline-offset: -3px; }

/* 効果選択の見出しだけ、左上の最小化ボタンから離す。候補の幅は変えない。 */
#app #battlePanel.battle-visibility-enabled :is(.card-inspection-head, .battle-effect-target-head) {
  padding-inline-start: 18px;
}

/* 武器を受け付ける合図を残し、計算と結果の下地だけを共通化する。 */
#app #battlePanel:not(.battle-drag-over) {
  border-color: #b5a27373;
  background:
    radial-gradient(ellipse at 50% 0%, #b69b4920, transparent 55%),
    linear-gradient(180deg, #17342df5, #0b211df5);
}
#app .formula-side {
  border-color: #b5a27352;
  background: #0b211e;
}

.battle-panel {
  --battle-step-row: 24px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% -18%, rgba(255, 225, 154, 0.11), transparent 44%),
    radial-gradient(ellipse at 50% 110%, rgba(104, 208, 200, 0.07), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%),
    rgba(32, 36, 31, 0.66);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    inset 0 -1px 0 rgba(0, 0, 0, 0.26),
    inset 0 -18px 32px rgba(0, 0, 0, 0.12),
    0 10px 22px rgba(0, 0, 0, 0.14);
}

.card.battle-weapon-selected {
  border-color: #ffe19a;
  filter: brightness(1.08) saturate(1.08);
  box-shadow:
    0 0 0 2px rgba(255, 225, 154, 0.62),
    0 0 18px rgba(255, 225, 154, 0.36),
    0 0 30px rgba(116, 232, 158, 0.14);
  animation: battle-selection-breathe 1800ms ease-in-out infinite;
}

.card.battle-predesignated-target,
.unit.battle-predesignated-target {
  z-index: 8;
  border-color: rgba(116, 232, 200, 0.94);
  filter: brightness(1.08) saturate(1.08);
  box-shadow:
    0 0 0 2px rgba(116, 232, 200, 0.58),
    0 0 18px rgba(116, 232, 200, 0.38),
    0 0 30px rgba(255, 225, 154, 0.18);
  animation: battle-predesignation-breathe 1600ms ease-in-out infinite;
}

.battle-predesignation-badge {
  position: absolute;
  top: 24px;
  right: -5px;
  z-index: 26;
  padding: 3px 6px;
  border: 1px solid rgba(179, 255, 235, 0.9);
  border-radius: 999px 0 0 999px;
  background: linear-gradient(180deg, rgba(31, 112, 100, 0.98), rgba(18, 67, 64, 0.98));
  color: #e8fff7;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

/* 通信の差し替え用要素が空でも、外枠だけを表示しない。 */
.battle-panel:empty,
.battle-panel:has(> .friend-match-content):not(:has(> :not([hidden]):not(:empty))) {
  display: none;
}

/* 通信の差し替え用要素で、共通戦闘表示の高さの基準を変えない。 */
.battle-panel > :is(.friend-battle-presentation, .friend-match-content):not([hidden]) {
  display: contents;
}

.friend-match-content.is-presenting .battle-special-wait-choice-panel {
  display: none;
}

.battle-panel.battle-drag-over {
  outline: 2px solid rgba(245, 211, 111, 0.95);
  outline-offset: 4px;
  background: rgba(245, 211, 111, 0.08);
}

.battle-panel[data-mode="attack-choice"],
.battle-panel[data-mode="attack-call"],
.battle-panel[data-mode="block-call"],
.battle-panel[data-mode="block-choice"],
.battle-panel[data-mode="weapon-choice"],
.battle-panel[data-mode="processing"],
.battle-panel[data-mode="damage-preview"],
.battle-panel[data-mode="result"] {
  padding: 0;
  overflow: hidden;
}

.battle-grid {
  display: grid;
  gap: 8px;
}

.battle-step-note {
  color: var(--muted);
  font-size: 12px;
}

.battle-step-trail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
  justify-self: center;
  box-sizing: border-box;
  width: min(100%, 520px);
  height: var(--battle-step-row);
  min-height: var(--battle-step-row);
  max-height: var(--battle-step-row);
  overflow: visible;
}

.battle-step-trail span {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  min-width: 0;
  padding: 0 2px;
  border: 1px solid rgba(177, 207, 226, 0.22);
  border-radius: 999px;
  background: rgba(13, 18, 19, 0.58);
  color: #97aab5;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.battle-step-trail span.is-done {
  border-color: rgba(127, 183, 143, 0.34);
  background: rgba(38, 72, 50, 0.42);
  color: #b9d8bd;
}

.battle-step-trail span.is-active {
  border-color: rgba(255, 225, 128, 0.72);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 241, 178, 0.22), transparent 62%),
    linear-gradient(180deg, rgba(255, 225, 128, 0.16), transparent),
    rgba(67, 48, 26, 0.72);
  color: #ffe19a;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 12px rgba(255, 204, 91, 0.18),
    0 0 22px rgba(255, 204, 91, 0.08);
}

.battle-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.battle-grid select {
  min-width: 0;
  border: 1px solid #606858;
  border-radius: 7px;
  padding: 8px;
  background: #171a17;
  color: var(--text);
}

.battle-attack-panel,
.battle-weapon-panel,
.battle-block-panel {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 338px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% -16%, rgba(255, 225, 154, 0.08), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 30%),
    linear-gradient(180deg, rgba(24, 35, 39, 0.76), rgba(18, 22, 21, 0.74)),
    rgba(16, 19, 18, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    inset 0 -18px 32px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

.battle-attack-head,
.battle-weapon-head,
.battle-block-head {
  display: grid;
  gap: 3px;
}

.battle-attack-head span,
.battle-weapon-head span,
.battle-block-head span {
  color: #aee7ff;
  font-size: 11px;
  font-weight: 900;
}

.battle-attack-head strong,
.battle-weapon-head strong,
.battle-block-head strong {
  color: #fff3c0;
  font-size: 16px;
}

.battle-attack-head small,
.battle-weapon-head small,
.battle-block-head small {
  color: #c8d9d4;
  font-size: 11px;
}

:is(.friend-match-active, .verified-cpu-active) .battle-weapon-head .friend-battle-unit-inspect {
  display: inline;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  vertical-align: baseline;
  text-decoration: underline dotted;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

:is(.friend-match-active, .verified-cpu-active) .battle-weapon-head .friend-battle-unit-inspect:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.battle-weapon-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.battle-weapon-columns.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.battle-weapon-wait {
  display: grid;
  place-items: center;
  min-height: 118px;
  border: 1px dashed rgba(218, 246, 255, 0.2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: rgba(10, 14, 14, 0.28);
}

.battle-weapon-auto-notice {
  padding: 7px 10px;
  border: 1px solid rgba(174, 231, 255, 0.3);
  border-radius: 7px;
  color: #d9f5ff;
  background: rgba(35, 93, 111, 0.22);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.battle-weapon-resolve,
.battle-block-resolve {
  justify-self: end;
}

.battle-attack-route {
  position: relative;
  display: grid;
  grid-template-columns: minmax(76px, 1fr) auto minmax(76px, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 225, 154, 0.26);
  border-radius: 9px;
  background:
    linear-gradient(90deg, rgba(108, 230, 255, 0.14), transparent 35%, transparent 65%, rgba(255, 131, 96, 0.13)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01) 36%, rgba(0, 0, 0, 0.18)),
    rgba(9, 14, 15, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

.battle-attack-route::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 15%;
  left: 15%;
  height: 2px;
  background:
    linear-gradient(90deg, transparent, rgba(115, 231, 255, 0.45) 18%, rgba(255, 225, 154, 0.84) 50%, rgba(255, 111, 80, 0.5) 82%, transparent);
  box-shadow:
    0 0 10px rgba(255, 225, 154, 0.32),
    0 0 18px rgba(108, 230, 255, 0.14);
  transform: translateY(-50%);
  pointer-events: none;
}

.battle-attack-route.is-reversed::before {
  background:
    linear-gradient(90deg, transparent, rgba(255, 111, 80, 0.5) 18%, rgba(255, 225, 154, 0.84) 50%, rgba(115, 231, 255, 0.45) 82%, transparent);
}

.battle-attack-route .battle-choice-card,
.battle-route-placeholder {
  position: relative;
  z-index: 1;
  justify-self: center;
  width: min(100%, 102px);
  max-width: 102px;
}

.battle-attack-route > .battle-route-attacker {
  border-color: rgba(114, 222, 255, 0.56);
  box-shadow:
    0 0 0 1px rgba(114, 222, 255, 0.2),
    0 9px 18px rgba(0, 0, 0, 0.26),
    0 0 18px rgba(72, 202, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.battle-attack-route > .battle-route-target {
  border-color: rgba(255, 171, 112, 0.58);
  box-shadow:
    0 0 0 1px rgba(255, 171, 112, 0.2),
    0 9px 18px rgba(0, 0, 0, 0.26),
    0 0 18px rgba(255, 117, 78, 0.19),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.battle-attack-route > .battle-route-blocker {
  border-color: rgba(156, 238, 188, 0.62);
  box-shadow:
    0 0 0 1px rgba(156, 238, 188, 0.22),
    0 9px 18px rgba(0, 0, 0, 0.26),
    0 0 18px rgba(80, 220, 146, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.battle-attack-route-arrow {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 225, 154, 0.66);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 248, 202, 0.32), transparent 42%),
    linear-gradient(180deg, rgba(255, 205, 91, 0.34), rgba(61, 38, 12, 0.88)),
    rgba(32, 25, 12, 0.78);
  color: #ffe19a;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 244, 191, 0.45);
  box-shadow:
    0 0 0 2px rgba(255, 225, 154, 0.08),
    0 0 18px rgba(255, 205, 91, 0.32),
    0 0 26px rgba(255, 111, 80, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.battle-attack-call-panel {
  align-content: start;
  justify-content: stretch;
  min-height: 286px;
}

.battle-attack-call-route {
  isolation: isolate;
}

.battle-attack-call-route::before {
  height: 3px;
  animation: battle-route-call-line 920ms ease-out both;
}

.battle-attack-call-route > .battle-choice-card:first-child,
.battle-attack-call-route > .battle-choice-card.battle-route-attacker {
  animation: battle-route-attacker-call 720ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.battle-attack-call-route > .battle-choice-card:last-child,
.battle-attack-call-route > .battle-choice-card.battle-route-target {
  animation: battle-route-target-call 720ms ease-out both;
}

.battle-attack-call-route .battle-attack-route-arrow {
  animation: battle-route-arrow-call 900ms ease-out both;
}

.battle-block-call-route {
  background:
    linear-gradient(90deg, rgba(108, 230, 255, 0.14), transparent 34%, transparent 64%, rgba(113, 238, 164, 0.15)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01) 36%, rgba(0, 0, 0, 0.18)),
    rgba(9, 14, 15, 0.42);
}

.battle-block-call-route.is-reversed {
  background:
    linear-gradient(90deg, rgba(113, 238, 164, 0.15), transparent 34%, transparent 64%, rgba(108, 230, 255, 0.14)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01) 36%, rgba(0, 0, 0, 0.18)),
    rgba(9, 14, 15, 0.42);
}

.battle-block-call-route::before {
  background:
    linear-gradient(90deg, transparent, rgba(115, 231, 255, 0.45) 18%, rgba(255, 225, 154, 0.84) 50%, rgba(113, 238, 164, 0.54) 82%, transparent);
}

.battle-block-call-route.is-reversed::before {
  background:
    linear-gradient(90deg, transparent, rgba(113, 238, 164, 0.54) 18%, rgba(255, 225, 154, 0.84) 50%, rgba(115, 231, 255, 0.45) 82%, transparent);
}

.battle-attack-call-route.is-reversed > .battle-choice-card.battle-route-attacker {
  animation-name: battle-route-attacker-call-reversed;
}

.battle-attack-call-route.is-reversed > .battle-choice-card.battle-route-target {
  animation-name: battle-route-target-call-reversed;
}

.battle-block-call-route > .battle-choice-card.battle-route-blocker {
  animation: battle-route-blocker-call 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.battle-block-call-route.is-reversed > .battle-choice-card.battle-route-blocker {
  animation-name: battle-route-blocker-call-reversed;
}

.battle-attack-call-caption {
  justify-self: center;
  width: min(100%, 320px);
  padding: 6px 10px;
  border: 1px solid rgba(255, 225, 154, 0.22);
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 225, 154, 0.12), transparent),
    rgba(8, 12, 13, 0.42);
  color: #ffe19a;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 16px rgba(255, 205, 91, 0.12);
}

.battle-route-card {
  cursor: default;
}

.battle-route-placeholder {
  display: grid;
  place-items: center;
  gap: 4px;
  aspect-ratio: 2 / 3;
  padding: 8px;
  border: 1px dashed rgba(218, 246, 255, 0.26);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 20%, rgba(174, 231, 255, 0.08), transparent 52%),
    rgba(10, 14, 14, 0.3);
  box-sizing: border-box;
  color: #d7e6df;
  text-align: center;
}

.battle-route-placeholder span {
  color: #aee7ff;
  font-size: 10px;
  font-weight: 900;
}

.battle-route-placeholder strong {
  color: #fff3c0;
  font-size: 12px;
  line-height: 1.25;
}

.battle-attack-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: auto;
}

.battle-attack-cancel,
.battle-attack-resolve {
  width: 100%;
}

.battle-attack-resolve,
.battle-weapon-resolve {
  font-weight: 900;
}

.battle-attack-cancel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 48%),
    linear-gradient(180deg, rgba(151, 172, 190, 0.2), rgba(30, 42, 54, 0.16)),
    #26313b;
  border-color: #6f8497;
  color: #e5eef5;
  font-weight: 800;
}

.battle-choice-section {
  display: grid;
  gap: 5px;
}

.battle-attack-choice-section .battle-choice-card {
  flex-basis: 82px;
}

.battle-attack-position-columns {
  display: grid;
  grid-template-columns:
    minmax(0, var(--attack-front-track, 1fr))
    minmax(0, var(--attack-back-track, 1fr));
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.battle-attack-position-group {
  display: grid;
  grid-template-rows: auto auto;
  gap: 4px;
  align-content: start;
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(218, 246, 255, 0.14);
  border-radius: 8px;
  background: rgba(9, 15, 15, 0.34);
}

.battle-attack-position-group.has-no-candidates {
  align-self: stretch;
  grid-template-rows: auto minmax(0, 1fr);
}

.battle-attack-position-group.is-front {
  border-color: rgba(255, 211, 116, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 211, 116, 0.055), transparent 52%),
    rgba(9, 15, 15, 0.34);
}

.battle-attack-position-group.is-back {
  border-color: rgba(115, 210, 226, 0.22);
  background:
    linear-gradient(180deg, rgba(115, 210, 226, 0.055), transparent 52%),
    rgba(9, 15, 15, 0.34);
}

.battle-attack-position-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
}

.battle-attack-position-head strong {
  color: #fff0b7;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.battle-attack-position-group.is-back .battle-attack-position-head strong {
  color: #c9f2f6;
}

.battle-attack-position-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.battle-attack-position-group .battle-choice-list {
  justify-content: safe center;
  min-height: 102px;
  padding: 9px 8px 6px;
}

.battle-attack-position-group .battle-choice-empty {
  min-height: 88px;
  font-size: 10px;
}

.battle-attack-position-group.has-no-candidates .battle-choice-list {
  min-height: 70px;
  padding-block: 6px;
}

.battle-attack-position-group.has-no-candidates .battle-choice-empty {
  min-height: 56px;
}

.battle-choice-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.battle-choice-empty {
  flex: 1 0 100%;
  display: grid;
  place-items: center;
  min-height: 88px;
  border: 1px dashed rgba(218, 246, 255, 0.22);
  border-radius: 8px;
  background: rgba(10, 14, 14, 0.3);
  color: #c8d9d4;
  font-size: 12px;
  font-weight: 800;
}

.battle-choice-list {
  display: flex;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 9px 2px 6px 8px;
  touch-action: pan-x pinch-zoom;
  -webkit-overflow-scrolling: touch;
}

.battle-choice-card {
  position: relative;
  flex: 0 0 88px;
  aspect-ratio: 2 / 3;
  overflow: visible;
  appearance: none;
  border: 1px solid rgba(218, 246, 255, 0.28);
  border-radius: var(--compact-card-corner-radius);
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), transparent 18%),
    linear-gradient(180deg, transparent 58%, rgba(0, 0, 0, 0.22)),
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 38%),
    #24302e;
  color: inherit;
  cursor: pointer;
  touch-action: pan-x pinch-zoom;
  box-shadow:
    0 7px 16px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -14px 22px rgba(0, 0, 0, 0.2);
}

.battle-blocker-choice-section .battle-choice-card {
  flex-basis: 88px;
}

.battle-choice-card .level-badge {
  top: -5px;
  left: -5px;
  width: 21px;
  height: 21px;
  font-size: 11px;
}

.battle-choice-card .battle-choice-commander-badge {
  top: -7px;
  z-index: 7;
  min-width: 40px;
  padding: 2px 8px 3px;
  font-size: 10px;
  white-space: nowrap;
}

.battle-choice-card.has-card-art {
  background-image:
    linear-gradient(180deg, rgba(5, 10, 10, 0.02), rgba(5, 10, 10, 0.32)),
    var(--card-art);
  background-position: center;
  background-size: cover;
}

@supports (-webkit-touch-callout: none) {
  /* 縦画面のWebKitで初回の背景絵が描かれない場合があるため、武器候補の面を合成する。 */
  body.mobile-layout .battle-weapon-panel .battle-choice-card.has-card-art {
    transform: translateZ(0);
  }
}

.battle-choice-card:focus-visible,
.battle-choice-card.is-selected {
  border-color: rgba(255, 225, 154, 0.88);
  outline: none;
  box-shadow:
    0 0 0 2px rgba(255, 225, 154, 0.34),
    0 0 14px rgba(255, 225, 154, 0.18),
    0 10px 22px rgba(0, 0, 0, 0.36);
}

.battle-choice-card.is-selected {
  box-shadow:
    0 0 0 2px rgba(255, 225, 154, 0.62),
    0 0 20px rgba(255, 225, 154, 0.34),
    0 0 34px rgba(116, 232, 158, 0.16),
    0 10px 22px rgba(0, 0, 0, 0.36);
  animation: battle-selection-breathe 1800ms ease-in-out infinite;
}

/* タッチ時は枠と光で選択を示す。hoverの居残りと画像の再合成を避ける。 */
@media (hover: hover) and (pointer: fine) {
  .battle-choice-card:hover:not(.is-selected) {
    border-color: rgba(255, 225, 154, 0.88);
    box-shadow:
      0 0 0 2px rgba(255, 225, 154, 0.34),
      0 0 14px rgba(255, 225, 154, 0.18),
      0 10px 22px rgba(0, 0, 0, 0.36);
  }

  .battle-choice-card:hover,
  .battle-choice-card:focus-visible {
    filter: brightness(1.04) saturate(1.04);
  }

  .battle-choice-card.is-selected {
    filter: brightness(1.08) saturate(1.08);
  }
}

.battle-choice-none {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 44%),
    rgba(22, 25, 22, 0.95);
}

.battle-choice-card-info {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  display: grid;
  gap: 1px;
  padding: 4px;
  border-radius: 6px;
  background: rgba(5, 8, 8, 0.78);
}

:lang(en) .battle-choice-card-info > strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
}

:lang(en) .battle-choice-card-info > span {
  white-space: normal;
  overflow: visible;
}

.battle-choice-stat {
  display: block;
  white-space: nowrap;
}

:lang(en) .battle-choice-card-info .battle-choice-attributes {
  display: block;
  white-space: normal;
}

:lang(en) .battle-choice-card-info .battle-weapon-attrs {
  display: block;
}

:lang(en) .battle-choice-card-info small {
  white-space: normal;
}

.battle-choice-estimate {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 34px;
  padding: 3px 5px;
  border: 1px solid rgba(255, 231, 154, 0.36);
  border-radius: 7px;
  background: rgba(14, 9, 2, 0.78);
  box-shadow: 0 0 12px rgba(255, 205, 89, 0.16);
}

.battle-choice-estimate span {
  color: #ffe9a5;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.battle-choice-estimate strong {
  color: #fff9d6;
  font-size: 15px;
  line-height: 1;
}

.battle-choice-estimate small {
  max-width: 70px;
  overflow: hidden;
  color: #b7f2ff;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-choice-card-info strong,
.battle-choice-card-info span,
.battle-choice-card-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-choice-card-info strong {
  color: #fff7cf;
  font-size: 10px;
}

@media (orientation: landscape) {
  body:not(.mobile-layout):not(.mobile-landscape-layout) .battle-choice-card-info strong {
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    line-height: 1.25;
  }
}

.battle-choice-card-info span {
  color: #b8e7ff;
  font-size: 9px;
  font-weight: 800;
}

.battle-choice-card-info .battle-weapon-attrs,
.battle-choice-card-info .battle-weapon-attr-token {
  display: inline;
  overflow: visible;
  color: inherit;
  font: inherit;
  text-overflow: clip;
}

.battle-choice-card-info .battle-weapon-attr-token.battle-attribute-match {
  color: var(--battle-attribute-link-color, #aee7ff);
  text-shadow:
    0 0 5px var(--battle-attribute-link-glow, rgba(174, 231, 255, 0.72)),
    0 0 11px var(--battle-attribute-link-glow, rgba(174, 231, 255, 0.72));
}

.battle-attribute-match {
  position: relative;
  z-index: 2;
  display: inline-block;
  color: var(--battle-attribute-link-color, #aee7ff);
  text-shadow:
    0 0 5px var(--battle-attribute-link-glow, rgba(174, 231, 255, 0.72)),
    0 0 11px var(--battle-attribute-link-glow, rgba(174, 231, 255, 0.72));
  animation: battle-attribute-link-pulse 720ms ease-out both;
  animation-delay: 120ms;
}

.battle-attribute-slash { --battle-attribute-link-color: #ffd27f; --battle-attribute-link-glow: rgba(255, 191, 79, 0.78); }
.battle-attribute-pierce { --battle-attribute-link-color: #a9edff; --battle-attribute-link-glow: rgba(90, 211, 255, 0.76); }
.battle-attribute-blow { --battle-attribute-link-color: #ffb184; --battle-attribute-link-glow: rgba(255, 123, 78, 0.74); }
.battle-attribute-arrow { --battle-attribute-link-color: #d5f4ff; --battle-attribute-link-glow: rgba(154, 225, 255, 0.76); }
.battle-attribute-guard { --battle-attribute-link-color: #a9d7ff; --battle-attribute-link-glow: rgba(90, 164, 255, 0.76); }
.battle-attribute-magica { --battle-attribute-link-color: #d5b4ff; --battle-attribute-link-glow: rgba(166, 104, 255, 0.78); }
.battle-attribute-fire { --battle-attribute-link-color: #ffad7d; --battle-attribute-link-glow: rgba(255, 91, 48, 0.8); }
.battle-attribute-water { --battle-attribute-link-color: #88d7ff; --battle-attribute-link-glow: rgba(50, 158, 255, 0.78); }
.battle-attribute-ice { --battle-attribute-link-color: #c2f5ff; --battle-attribute-link-glow: rgba(111, 224, 255, 0.8); }
.battle-attribute-wind { --battle-attribute-link-color: #a6f2c7; --battle-attribute-link-glow: rgba(66, 213, 139, 0.76); }
.battle-attribute-thunder { --battle-attribute-link-color: #fff18a; --battle-attribute-link-glow: rgba(255, 218, 47, 0.82); }
.battle-attribute-ground { --battle-attribute-link-color: #e3bd83; --battle-attribute-link-glow: rgba(181, 123, 52, 0.78); }
.battle-attribute-light { --battle-attribute-link-color: #fff8c9; --battle-attribute-link-glow: rgba(255, 238, 139, 0.84); }
.battle-attribute-dark { --battle-attribute-link-color: #c2a5ff; --battle-attribute-link-glow: rgba(118, 73, 218, 0.82); }

.battle-choice-card-info small {
  color: #dce7dc;
  font-size: 8px;
}

.battle-special-wait-choice-panel {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(255, 225, 154, 0.34);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 231, 154, 0.12), transparent 42%),
    rgba(16, 13, 7, 0.66);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.22);
}

.battle-special-wait-choice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.battle-special-wait-choice-head > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.battle-special-wait-choice-head strong {
  color: #fff0a8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}

.battle-special-wait-choice-head span {
  overflow: hidden;
  color: #efe8d0;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-special-wait-skip {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 12px;
  border-color: rgba(255, 225, 154, 0.42);
  color: #fff2be;
  font-size: 11px;
  font-weight: 900;
}

.battle-special-choice-section .battle-choice-list {
  padding-top: 6px;
  padding-bottom: 5px;
}

.battle-special-choice-card {
  flex-basis: 78px;
}

body > .nonbattle-special-wait-panel {
  position: fixed;
  z-index: 89;
  top: var(--nonbattle-special-wait-top, 140px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px));
  max-height: min(420px, calc(100dvh - var(--nonbattle-special-wait-top, 140px) - 16px));
  overflow: auto;
}
body > .nonbattle-special-wait-panel .battle-special-wait-choice-panel {
  background: #171a13f5;
  padding: 12px;
  box-shadow: 0 12px 32px #0008;
}
body > .nonbattle-special-wait-panel .battle-special-wait-skip { min-height: 44px; }
#app #controlPanel:has(.battle-special-wait-choice-overlay) {
  z-index: 89;
  overflow: visible;
}
#app #battlePanel:has(.battle-special-wait-choice-overlay) {
  overflow: visible;
}
.app:not(.mobile-layout):not(.mobile-landscape-layout) .battle-stage .battle-special-wait-choice-overlay {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px));
  max-height: min(360px, 60dvh);
  overflow: auto;
}

@media (orientation: landscape) {
  body:not(.mobile-layout):not(.mobile-landscape-layout) > .nonbattle-special-wait-panel,
  body.mobile-landscape-layout > .nonbattle-special-wait-panel,
  .app:not(.mobile-layout):not(.mobile-landscape-layout) .battle-stage .battle-special-wait-choice-overlay {
    width: min(var(--special-wait-landscape-width, 366px), calc(100vw - 24px));
  }

  body:not(.mobile-layout):not(.mobile-landscape-layout) .battle-special-wait-choice-panel {
    min-width: 0;
    padding: 12px;
  }

  body:not(.mobile-layout):not(.mobile-landscape-layout) .battle-special-choice-section {
    min-width: 0;
  }

  body:not(.mobile-layout):not(.mobile-landscape-layout) .battle-special-wait-choice-head span {
    white-space: normal;
  }
}

.battle-result {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 8px;
  box-sizing: border-box;
}

.battle-result.battle-process-only {
  align-content: start;
  gap: 8px;
  min-height: 0;
}

.battle-result.battle-process-only .battle-head-stack {
  min-height: 45px;
}

/* 演出の有無ではなく、処理・計算・結果を通した共通の行配分にする。 */
.battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) {
  --battle-head-row: 58px;
  --battle-stage-row-min: 156px;
  --battle-calc-row-min: 0px;
  display: grid;
  grid-template-rows:
    var(--battle-step-row)
    var(--battle-head-row)
    minmax(var(--battle-stage-row-min), auto)
    minmax(var(--battle-calc-row-min), 1fr);
  align-content: start;
}

.battle-result.has-inline-special-choice:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated):not(.final-blow) {
  grid-template-rows:
    var(--battle-step-row)
    var(--battle-head-row)
    auto
    minmax(var(--battle-stage-row-min), auto)
    minmax(var(--battle-calc-row-min), 1fr);
}

.battle-result.direct-attack {
  min-height: 282px;
}

.battle-result.battle-interrupt {
  align-content: start;
  gap: 10px;
  min-height: 282px;
}

.battle-result.battle-interrupt.final-blow {
  min-height: 312px;
}

.battle-head-stack {
  position: relative;
  min-height: 45px;
}

.battle-head-copy {
  display: contents;
}

.battle-turn-status {
  display: none;
}

.battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-head-stack {
  height: var(--battle-head-row);
  min-height: var(--battle-head-row);
  max-height: var(--battle-head-row);
  overflow: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}

.battle-result.battle-interrupt .battle-head-stack {
  min-height: auto;
}

.battle-result-head,
.battle-process-head,
.battle-correction-head {
  display: grid;
  gap: 3px;
}

.battle-process-head {
  display: none;
}

.battle-correction-head {
  display: none;
}

.battle-result.has-delayed-damage-calc-result .battle-correction-head {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  justify-items: start;
  text-align: left;
  animation: damage-calc-correction-head-out 200ms ease-out var(--damage-calc-result-delay, 1200ms) both;
}

.battle-result.has-delayed-damage-calc-result .battle-result-head {
  animation: battle-head-transition-in 240ms ease-out var(--damage-calc-result-delay, 1200ms) both;
}

.battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-result-head,
.battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-process-head {
  min-height: var(--battle-head-row);
  align-content: start;
}

.battle-result.has-battle-process .clash-gauge,
.battle-result.has-battle-process .battle-formula-grid {
  animation: battle-calc-reveal 220ms ease-out var(--battle-process-ms, 0ms) both;
}

.battle-result.has-battle-process .battle-process-head {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  justify-items: start;
  text-align: left;
  animation: battle-head-wait var(--battle-process-ms, 1000ms) ease-out both;
}

.battle-result.battle-process-only.has-battle-process .battle-process-head {
  animation: battle-head-transition-in 260ms ease-out both;
}

.battle-result.battle-process-only.has-battle-process .battle-process-detail {
  animation: battle-process-hold 260ms ease-out both;
}

.battle-result.has-head-transition .battle-result-head {
  animation: battle-head-transition-in 260ms ease-out both;
}

.battle-result.damage-calc-staged.has-head-transition .battle-result-head {
  animation: battle-head-transition-in 260ms ease-out calc(0ms - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.battle-result.has-battle-process .battle-result-head,
.battle-result.has-battle-process.has-head-transition .battle-result-head {
  animation: battle-head-transition-in 220ms ease-out var(--battle-process-ms, 0ms) both;
}

.battle-result.has-head-transition.has-delayed-damage-calc-result .battle-result-head {
  animation: battle-head-transition-in 240ms ease-out var(--damage-calc-result-delay, 1200ms) both;
}

.battle-calc-stack {
  position: relative;
  display: grid;
  min-height: 0;
}

.battle-calc-content {
  display: grid;
  gap: 6px;
}

/* 本番と同じ計算欄の実寸だけを予約し、未確定の数値は表示・操作させない。 */
.battle-calc-reservation {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.battle-interrupt-detail {
  align-self: start;
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 190, 118, 0.24);
  border-radius: var(--ui-radius-md, 8px);
  background: rgba(39, 28, 24, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.battle-interrupt-detail strong {
  color: #ffd79a;
  font-size: 18px;
}

.battle-interrupt-detail span {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.battle-process-detail {
  display: none;
}

.battle-result.has-battle-process .battle-process-detail {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: visible;
  padding-right: 2px;
  animation: battle-process-wait var(--battle-process-ms, 1000ms) ease-out both;
}

.battle-result.battle-process-only.has-battle-process .battle-process-detail {
  position: absolute;
  inset: 0;
  padding-right: 0;
  overflow: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}

.battle-process-weapons {
  display: grid;
  container-type: inline-size;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.battle-process-weapon {
  position: relative;
  min-width: 0;
  min-height: 0;
  /* 2列の説明欄の実幅から文字と余白を決め、端末の向きには依存させない。 */
  font-size: clamp(11px, 2.5cqi, 17px);
  padding: 0.5em;
  overflow-wrap: anywhere;
  border: 1px solid rgba(104, 128, 177, 0.58);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 48%),
    rgba(17, 20, 24, 0.92);
  color: #e7edff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 10px 24px rgba(0, 0, 0, 0.26);
}

.battle-process-weapon.is-effect-destroyed {
  border-color: rgba(255, 126, 88, 0.84);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 112, 77, 0.2), transparent 52%),
    rgba(34, 18, 18, 0.94);
  box-shadow:
    inset 0 0 20px rgba(255, 88, 61, 0.2),
    0 0 18px rgba(255, 99, 67, 0.3);
  animation: battle-process-effect-break 1040ms ease-out both;
}

.battle-process-effect-break {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 222, 172, 0.88);
  border-radius: 999px;
  background: rgba(92, 31, 24, 0.94);
  color: #fff0cf;
  font-size: 0.85em;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 0 12px rgba(255, 104, 72, 0.42);
  animation: battle-process-effect-break-label 1040ms ease-out both;
}

.battle-process-weapon > span,
.battle-process-weapon > strong,
.battle-process-weapon > p {
  display: block;
}

.battle-process-weapon > span {
  color: #aebfe9;
  font-size: 0.85em;
  font-weight: 900;
  line-height: 1.15;
}

.battle-process-weapon > strong {
  margin-top: 1px;
  color: #ffe19a;
  font-size: 1.125em;
  line-height: 1.3;
}

.battle-process-weapon > p {
  margin: 0.3em 0 0;
  color: #d8e3ff;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.45;
}

.battle-process-weapon > .battle-process-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15em 0.6em;
}

.battle-process-traits {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em;
  flex-basis: 100%;
}

.battle-process-stat {
  white-space: nowrap;
}

.battle-process-weapon.no-weapon {
  border-color: rgba(173, 181, 160, 0.46);
  background: rgba(19, 21, 18, 0.9);
}

.battle-process-effect {
  color: #f2efe4;
  white-space: normal;
}

@media (max-width: 620px) and (orientation: portrait),
  (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  .battle-panel {
    min-height: 0;
    padding: 7px;
    border-radius: 7px;
    overflow: hidden;
  }

  /* 固定位置と内部操作を戦闘パネル側へ集約し、通常盤面のCSSから独立させる。 */
  .control-panel.has-pending-battle .battle-panel {
    --mobile-battle-available-height: max(0px, calc(var(--app-usable-height) - var(--mobile-battle-panel-top) - var(--mobile-battle-panel-bottom) + var(--mobile-battle-gap-saving, 0px)));
    --mobile-battle-route-card-width: clamp(70px, 10.6dvh, 78px);
    --mobile-battle-candidate-card-width: clamp(68px, 10.1dvh, 74px);
    position: fixed;
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + var(--mobile-battle-panel-inset));
    right: auto;
    top: calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-battle-panel-top) - var(--mobile-battle-gap-saving, 0px));
    bottom: auto;
    z-index: 80;
    display: block;
    box-sizing: border-box;
    width: calc(var(--app-usable-width) - (var(--mobile-battle-panel-inset) * 2));
    height: var(--mobile-battle-available-height);
    max-height: none;
    padding: var(--mobile-battle-panel-padding-block-start) var(--mobile-battle-panel-padding-inline) var(--mobile-battle-panel-padding-block-end);
    border-radius: 8px;
    background:
      linear-gradient(180deg, var(--phase-tint), transparent 22%),
      rgba(20, 23, 21, 0.74);
    backdrop-filter: blur(5px);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.28),
      0 14px 36px rgba(0, 0, 0, 0.32);
    overflow: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    scroll-padding-block: 8px 52px;
    pointer-events: auto;
  }

  .control-panel.has-pending-battle .battle-panel:is([data-mode="processing"], [data-mode="damage-preview"], [data-mode="result"]) {
    container: battle-viewport / size;
  }

  /* Safariの縦画面では、通知の下から効果対象を選べる高さを確保する。 */
  .app.mobile-layout.mobile-safari-layout:not(.native-app-layout) .control-panel.has-pending-battle .battle-panel[data-mode="unit-target-choice"] {
    --mobile-effect-target-top: max(
      calc(var(--app-viewport-offset-top) + var(--app-safe-top) + var(--mobile-battle-panel-top)),
      calc(var(--mobile-effect-target-notice-end, -8px) + 8px)
    );
    top: var(--mobile-effect-target-top);
    height: max(0px, calc(
      var(--app-viewport-offset-top) + var(--app-safe-top) + var(--app-usable-height)
      - var(--mobile-battle-panel-bottom) - var(--mobile-effect-target-top)
    ));
  }

  @media (max-width: 620px) and (max-height: 600px) {
    .app.mobile-layout.mobile-safari-layout:not(.native-app-layout) .battle-effect-target-panel {
      row-gap: 4px;
    }

    .app.mobile-layout.mobile-safari-layout:not(.native-app-layout) .battle-effect-target-panel .battle-choice-list {
      padding-block-start: 4px;
    }

    .app.mobile-layout.mobile-safari-layout:not(.native-app-layout) .battle-effect-target-panel .battle-choice-card {
      flex-basis: 78px;
    }
  }

  @supports (selector(:has(*))) {
    .control-panel.has-pending-battle:has(.battle-panel[data-mode="processing"]) .actions,
    .control-panel.has-pending-battle:has(.battle-panel[data-mode="damage-preview"]) .actions,
    .control-panel.has-pending-battle:has(.battle-panel[data-mode="result"]) .actions {
      pointer-events: none;
    }

    .control-panel.phase-finish.has-pending-battle:has(.battle-panel[data-mode="processing"]) .actions,
    .control-panel.phase-finish.has-pending-battle:has(.battle-panel[data-mode="damage-preview"]) .actions,
    .control-panel.phase-finish.has-pending-battle:has(.battle-panel[data-mode="result"]) .actions {
      pointer-events: auto;
    }
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"],
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"],
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"],
  .control-panel.has-pending-battle .battle-panel[data-mode="block-choice"],
  .control-panel.has-pending-battle .battle-panel[data-mode="weapon-choice"],
  .control-panel.has-pending-battle .battle-panel[data-mode="card-inspection"] {
    bottom: auto;
    height: auto;
    max-height: var(--mobile-battle-available-height);
    overflow-y: auto;
    pointer-events: auto;
  }

  /* 事前指定は候補数に応じた高さに留め、縦画面の盤面を必要以上に覆わない。 */
  .control-panel.has-pending-battle .battle-panel[data-mode="card-inspection"] {
    padding: 0;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="card-inspection"] .card-inspection-panel {
    min-height: 0;
    gap: 9px;
    padding: 11px 12px 12px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="card-inspection"] .card-inspection-list {
    min-height: 150px;
    padding: 9px;
  }

  .control-panel.has-pending-battle .battle-panel button,
  .control-panel.has-pending-battle .battle-choice-section,
  .control-panel.has-pending-battle .battle-choice-list,
  .control-panel.has-pending-battle .battle-panel select,
  .control-panel.has-pending-battle .battle-panel input,
  .control-panel.has-pending-battle .battle-panel textarea,
  .control-panel.has-pending-battle .battle-panel [role="button"],
  .control-panel.has-pending-battle .battle-panel [data-battle-visual-unit="true"],
  .control-panel.has-pending-battle .battle-choice-card,
  .control-panel.has-pending-battle .battle-weapon-resolve,
  .control-panel.has-pending-battle .battle-block-resolve {
    pointer-events: auto;
  }

  /* スマホ戦闘パネルの内部幅。上下余白はmobile_layout.cssの変数で管理する。 */
  .control-panel.has-pending-battle .battle-grid,
  .control-panel.has-pending-battle .battle-result {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: 100%;
  }

  .control-panel.has-pending-battle .battle-attack-panel,
  .control-panel.has-pending-battle .battle-block-panel,
  .control-panel.has-pending-battle .battle-weapon-panel {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
  }

  .control-panel.has-pending-battle .battle-step-trail {
    justify-self: stretch;
    width: 100%;
    max-width: none;
  }

  .battle-step-trail {
    gap: 3px;
  }

  .battle-step-trail span {
    padding-inline: 1px;
    font-size: 9.5px;
  }

  .battle-attack-panel,
  .battle-block-panel,
  .battle-weapon-panel {
    gap: 7px;
    min-height: 0;
    padding: 5px 7px 9px;
    border-radius: 7px;
  }

  /* 候補が多くても確定操作を見失わず、候補欄はそのままスクロールできる。 */
  .battle-attack-actions,
  .battle-block-resolve,
  .battle-weapon-resolve {
    position: sticky;
    bottom: 0;
    z-index: 12;
    min-height: 40px;
    box-shadow: 0 -5px 12px rgba(10, 15, 13, 0.55);
  }

  .battle-attack-actions {
    padding-block: 4px;
    background: rgba(18, 24, 21, 0.97);
  }

  .battle-attack-actions button {
    min-height: 40px;
  }

  .battle-attack-call-panel {
    min-height: 0;
  }

  .battle-attack-head strong,
  .battle-weapon-head strong,
  .battle-block-head strong {
    font-size: 13.5px;
    line-height: 1.25;
  }

  .battle-attack-head span,
  .battle-weapon-head span,
  .battle-block-head span,
  .battle-attack-head small,
  .battle-weapon-head small,
  .battle-block-head small {
    font-size: 10.5px;
  }

  .battle-weapon-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .battle-choice-list {
    gap: 5px;
    padding: 7px 2px 5px 5px;
    scroll-snap-type: x proximity;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"],
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"],
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] {
    overflow-x: hidden;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-panel,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-attack-panel,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-attack-panel {
    gap: 6px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-choice-list {
    min-height: 92px;
    padding-bottom: 7px;
  }

  .battle-attack-position-columns {
    grid-template-columns:
      minmax(88px, var(--attack-front-track, 1fr))
      minmax(88px, var(--attack-back-track, 1fr));
    gap: 5px;
  }

  .battle-attack-position-group {
    padding: 5px 4px;
  }

  .battle-attack-position-group .battle-choice-list {
    justify-content: safe center;
    min-height: 92px;
    padding: 8px 8px 5px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-route,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-attack-route,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-attack-route {
    gap: 7px;
    padding: 6px 7px;
    border-radius: 8px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-route::before,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-attack-route::before,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-attack-route::before {
    right: 18%;
    left: 18%;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-route .battle-choice-card,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-route-placeholder,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-attack-route .battle-choice-card,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-route-placeholder,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-attack-route .battle-choice-card,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-route-placeholder {
    width: min(100%, var(--mobile-battle-route-card-width));
    max-width: var(--mobile-battle-route-card-width);
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-route-arrow,
  .control-panel.has-pending-battle .battle-panel[data-mode="attack-call"] .battle-attack-route-arrow,
  .control-panel.has-pending-battle .battle-panel[data-mode="block-call"] .battle-attack-route-arrow {
    width: 27px;
    height: 27px;
    font-size: 16px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-choice-section .battle-choice-card {
    flex-basis: var(--mobile-battle-candidate-card-width);
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-choice-empty {
    min-height: 78px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-position-group.has-no-candidates .battle-choice-list {
    min-height: 62px;
    padding-block: 5px;
  }

  .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-position-group.has-no-candidates .battle-choice-empty {
    min-height: 50px;
  }

  .battle-choice-card,
  .battle-blocker-choice-section .battle-choice-card {
    flex-basis: 70px;
    border-radius: var(--compact-card-corner-radius);
    scroll-snap-align: start;
  }

  .battle-choice-card-info {
    right: 3px;
    bottom: 3px;
    left: 3px;
    gap: 0;
    padding: 3px;
    border-radius: 5px;
  }

  .battle-choice-card-info strong {
    font-size: 9px;
  }

  .battle-choice-card-info span,
  .battle-choice-card-info small {
    font-size: 8px;
  }

  .battle-choice-estimate {
    top: 4px;
    right: 4px;
    min-width: 28px;
    padding: 2px 4px;
  }

  .battle-choice-estimate strong {
    font-size: 13px;
  }

  .battle-special-wait-choice-panel {
    gap: 5px;
    padding: 6px;
    border-radius: 8px;
  }

  .battle-special-wait-choice-head {
    gap: 6px;
  }

  .battle-special-wait-choice-head strong {
    font-size: 11px;
  }

  .battle-special-wait-choice-head span {
    font-size: 9px;
  }

  .battle-special-wait-skip {
    min-height: 28px;
    padding: 0 8px;
    font-size: 10px;
  }

  .battle-special-choice-card {
    flex-basis: 66px;
  }

  .battle-weapon-wait {
    min-height: 72px;
    border-radius: 7px;
    font-size: 11.5px;
  }

  .battle-weapon-resolve,
  .battle-block-resolve {
    justify-self: stretch;
    min-height: 36px;
  }

  .battle-process-weapons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .battle-process-weapon {
    min-height: 0;
    border-radius: 7px;
  }

  .battle-result {
    align-content: start;
    gap: 7px;
    min-height: 0;
    padding: 5px 7px 9px;
  }

  .battle-calc-stack {
    min-height: 0;
  }

  .battle-calc-content {
    gap: 6px;
  }

  .clash-gauge {
    gap: 4px;
    min-height: 50px;
  }

  .clash-labels {
    gap: 6px;
    font-size: 10px;
  }

  .clash-labels strong {
    min-width: auto;
    font-size: 16px;
  }

  .clash-damage {
    max-width: 122px;
    gap: 3px;
    padding: 2px 6px;
    font-size: 10px;
    white-space: nowrap;
  }

  .clash-ko {
    font-size: 9px;
  }

  .clash-track {
    height: 26px;
  }

  .battle-formula-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .formula-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 7px;
    align-items: center;
    padding: 5px 7px;
    border-radius: 7px;
  }

  .formula-title {
    display: contents;
  }

  .formula-title > span {
    font-size: 10px;
    line-height: 1.15;
  }

  .formula-title strong {
    font-size: 19px;
  }

  .formula-line {
    grid-column: 1 / -1;
    gap: 3px;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
  }

  .formula-term {
    min-width: 0;
    gap: 2px;
    padding: 2px 4px;
    border-radius: 5px;
  }

  .formula-term em {
    font-size: 8px;
  }

  .formula-term strong,
  .formula-total {
    font-size: 10px;
  }

  .formula-equals,
  .formula-total {
    display: none;
  }

  .formula-plus {
    flex: 0 0 auto;
    color: rgba(242, 239, 228, 0.68);
    font-size: 9.5px;
    line-height: 1;
  }

  .battle-result.battle-process-only {
    align-content: start;
    gap: 7px;
    min-height: 0;
  }

  .battle-result.battle-process-only .battle-head-stack {
    min-height: 45px;
  }

  .battle-result.battle-process-only .battle-process-weapons {
    gap: 5px;
  }

}

.battle-result.has-battle-process .clash-center,
.battle-result.has-battle-process .clash-fill,
.battle-result.has-battle-process .clash-damage,
.battle-result.has-battle-process .segment-mod {
  animation-delay: var(--battle-process-ms, 0ms);
}

.battle-process-only .battle-unit-art,
.battle-process-only .battle-no-weapon,
.battle-process-only .battle-impact::before,
.battle-process-only .battle-impact::after,
.battle-process-only .battle-impact span {
  animation: none !important;
}

.battle-process-only .battle-weapon-left {
  animation: battle-weapon-ready-left var(--battle-weapon-ready-ms, 1900ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--battle-weapon-ready-delay, 0ms);
}

.battle-process-only .battle-weapon-right {
  animation: battle-weapon-ready-right var(--battle-weapon-ready-ms, 1900ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--battle-weapon-ready-delay, 0ms);
}

.speed-fast .battle-process-only {
  --battle-weapon-ready-ms: 1425ms;
}

.battle-process-only .battle-weapon-left.battle-weapon-kind-pierce {
  animation-name: battle-weapon-ready-pierce-left;
}

.battle-process-only .battle-weapon-right.battle-weapon-kind-pierce {
  animation-name: battle-weapon-ready-pierce-right;
}

.battle-process-only .battle-weapon-left.battle-weapon-kind-blow {
  animation-name: battle-weapon-ready-blow-left;
}

.battle-process-only .battle-weapon-right.battle-weapon-kind-blow {
  animation-name: battle-weapon-ready-blow-right;
}

.battle-process-only .battle-weapon-left.battle-weapon-kind-arrow {
  animation-name: battle-weapon-ready-arrow-left;
}

.battle-process-only .battle-weapon-right.battle-weapon-kind-arrow {
  animation-name: battle-weapon-ready-arrow-right;
}

.battle-process-only .battle-weapon-left.battle-weapon-guard {
  animation-name: battle-weapon-ready-guard-left;
}

.battle-process-only .battle-weapon-right.battle-weapon-guard {
  animation-name: battle-weapon-ready-guard-right;
}

.battle-process-only .battle-weapon-left.battle-magic-book {
  animation-name: battle-weapon-ready-guard-left;
}

.battle-process-only .battle-weapon-right.battle-magic-book {
  animation-name: battle-weapon-ready-guard-right;
}

.battle-process-only .battle-weapon-left.battle-magic-spell {
  opacity: 1;
  --battle-magic-spell-x: var(--battle-magic-spell-impact-x);
  transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(0.9);
  animation: none;
}

.battle-process-only .battle-weapon-right.battle-magic-spell {
  opacity: 1;
  --battle-magic-spell-x: calc(var(--battle-magic-spell-impact-x) * -1);
  transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(0.9);
  animation: none;
}

.battle-process-only .battle-magic-spell .battle-weapon-art,
.battle-process-only .battle-magic-spell::before,
.battle-process-only .battle-magic-spell::after,
.battle-process-only .battle-magic-circle-book {
  opacity: 0;
  animation: none;
}

.battle-result-head strong,
.battle-process-head strong,
.battle-correction-head strong {
  display: block;
  color: #ffe19a;
  font-size: 18px;
  line-height: 1.2;
  text-shadow: 0 0 14px rgba(255, 225, 154, 0.16);
}

.final-blow .battle-result-head strong {
  color: #fff0a8;
  font-size: 23px;
  letter-spacing: 0;
  text-shadow:
    0 0 14px rgba(255, 225, 154, 0.72),
    0 0 30px rgba(220, 82, 61, 0.42);
  animation: finish-title-pop 1900ms cubic-bezier(0.18, 0.9, 0.24, 1) var(--damage-motion-delay, 0ms) both;
}

.battle-process-head strong {
  color: #dfe7ff;
}

.battle-result-head > span,
.battle-process-head span,
.battle-correction-head span {
  display: block;
  margin-top: 4px;
  color: #cbc5b4;
  font-size: 12px;
  line-height: 1.35;
}

.battle-result.battle-interrupt .battle-result-head span {
  margin-top: 0;
}

.battle-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 156px;
  padding: 8px;
  border: 1px solid rgba(89, 97, 78, 0.9);
  border-radius: var(--ui-radius-md, 8px);
  background:
    radial-gradient(ellipse at 50% 106%, rgba(255, 225, 154, 0.13), transparent 58%),
    linear-gradient(90deg, rgba(245, 196, 86, 0.14), transparent 42%, transparent 58%, rgba(104, 208, 200, 0.14)),
    radial-gradient(circle at 50% 48%, rgba(255, 225, 154, 0.2), transparent 34%),
    radial-gradient(ellipse at 50% 52%, rgba(255, 255, 255, 0.035), transparent 64%),
    #151814;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    inset 0 -18px 34px rgba(0, 0, 0, 0.24),
    inset 0 0 30px rgba(255, 225, 154, 0.07),
    0 10px 26px rgba(0, 0, 0, 0.22),
    0 0 18px rgba(255, 225, 154, 0.055);
  overflow: visible;
  isolation: isolate;
}

.battle-stage .battle-special-wait-choice-overlay {
  position: absolute;
  z-index: 60;
  top: 18px;
  right: 8px;
  left: 8px;
  overflow: visible;
  align-self: auto;
  justify-self: stretch;
  background:
    linear-gradient(180deg, rgba(255, 231, 154, 0.14), transparent 42%),
    rgba(16, 13, 7, 0.72);
  backdrop-filter: blur(3px);
}

/* 動くイラストとは別の固定領域。戦士枠の内側を戦士、枠外の各陣営側を武器にする。 */
.battle-inspection-layer { position: absolute; inset: 0; z-index: 35; pointer-events: none; visibility: hidden; }
.battle-inspection-layer[data-ready="true"] { visibility: visible; }
.battle-stage .battle-inspection-layer button.battle-inspection-target {
  position: absolute;
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
  transform: none;
  animation: none;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
}
.battle-inspection-weapon { z-index: 1; }
.battle-inspection-unit { z-index: 2; }
.battle-stage .battle-inspection-unit:focus-visible { outline: 2px solid #f2dba1; outline-offset: -2px; }
.battle-stage .battle-inspection-weapon:focus-visible { outline: none; box-shadow: inset 0 -3px #f2dba1; }
.battle-stage .battle-inspection-weapon[aria-pressed="true"] { box-shadow: inset 0 -2px #e8cd8a; }
.battle-stage:has([data-battle-visual-weapon][data-battle-side="left"][aria-pressed="true"]) .battle-side-left .battle-weapon-name,
.battle-stage:has([data-battle-visual-weapon][data-battle-side="right"][aria-pressed="true"]) .battle-side-right .battle-weapon-name { color: #ffe19a; text-decoration: underline; text-underline-offset: 3px; }

.battle-stage .battle-special-wait-choice-overlay .battle-choice-section {
  min-height: 0;
}

.battle-stage .battle-special-wait-choice-overlay .battle-choice-list {
  overflow-y: visible;
}

@media (max-width: 620px) and (orientation: portrait),
  (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  .battle-stage .battle-special-wait-choice-overlay {
    top: 16px;
    right: 6px;
    left: 6px;
  }

}

.battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-stage {
  align-self: stretch;
}

.battle-stage-direct {
  min-height: 178px;
  background:
    radial-gradient(ellipse at 50% 106%, rgba(255, 225, 154, 0.12), transparent 58%),
    linear-gradient(90deg, rgba(245, 196, 86, 0.15), transparent 42%, transparent 58%, rgba(220, 107, 87, 0.13)),
    radial-gradient(circle at 50% 48%, rgba(255, 225, 154, 0.22), transparent 36%),
    #151814;
}

.final-blow .battle-stage {
  border-color: rgba(255, 224, 136, 0.82);
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 232, 142, 0.3), transparent 30%),
    radial-gradient(circle at 50% 48%, rgba(210, 69, 48, 0.22), transparent 54%),
    linear-gradient(90deg, rgba(255, 195, 86, 0.16), transparent 42%, transparent 58%, rgba(255, 108, 91, 0.14)),
    #151814;
  box-shadow:
    inset 0 0 34px rgba(255, 224, 136, 0.13),
    0 0 24px rgba(220, 82, 61, 0.16);
  animation: finish-stage-pulse 1900ms ease-out var(--damage-motion-delay, 0ms) both;
}

.battle-stage::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 1px;
  background:
    linear-gradient(180deg, transparent, rgba(242, 239, 228, 0.22), transparent);
  box-shadow: 0 0 18px rgba(255, 225, 154, 0.12);
}

.final-blow .battle-stage::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 238, 171, 0.28), transparent 32%),
    radial-gradient(circle at 50% 50%, transparent 36%, rgba(255, 111, 88, 0.16) 38%, transparent 58%);
  opacity: 0;
  animation: finish-stage-ring 1900ms ease-out var(--damage-motion-delay, 0ms) both;
}

.battle-actor {
  position: relative;
  z-index: 2;
  min-width: 0;
  display: grid;
  gap: 5px;
  justify-items: center;
}

.battle-unit-wrap {
  position: relative;
  width: min(106px, 100%);
  aspect-ratio: 2 / 3;
}

.battle-effect-hp-change {
  position: absolute;
  top: 34%;
  left: 50%;
  z-index: 14;
  pointer-events: none;
  font-size: clamp(18px, 1.8em, 28px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  transform: translate(-50%, -50%);
  animation: battle-effect-hp-change 820ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.battle-effect-hp-change.is-damage {
  color: #fff0e8;
  text-shadow:
    0 2px 2px rgba(45, 4, 0, 0.94),
    0 0 10px rgba(255, 76, 52, 0.96);
}

.battle-effect-hp-change.is-recovery {
  color: #f4fff8;
  text-shadow:
    0 2px 2px rgba(5, 43, 24, 0.92),
    0 0 10px rgba(188, 255, 220, 0.96);
}

.battle-unit-art {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(242, 219, 157, 0.44);
  border-radius: var(--compact-card-corner-radius);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, #30372e, #191d18);
  background-position: center;
  background-size: cover;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.28),
    0 14px 30px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(255, 225, 154, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -18px 26px rgba(0, 0, 0, 0.2);
  isolation: isolate;
}

.battle-unit-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 238, 171, 0.28), transparent 62%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%);
  opacity: 0;
  pointer-events: none;
}

.battle-unit-commander {
  overflow: visible;
  border-color: rgba(230, 90, 70, 0.9);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.36),
    0 0 0 2px rgba(220, 72, 58, 0.34),
    0 0 22px rgba(220, 72, 58, 0.2);
}

.battle-commander-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  padding: 2px 11px 3px;
  border: 1px solid rgba(255, 214, 185, 0.86);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(159, 37, 31, 0.98), rgba(104, 21, 22, 0.98));
  color: #fff1de;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.76);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.battle-weapon-layer {
  position: absolute;
  inset: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.battle-weapon-anchor {
  position: relative;
  width: min(106px, 100%);
  aspect-ratio: 2 / 3;
  justify-self: center;
  /* 直接魔法は、魔法陣を使用者側の端、攻撃本体を相手側に出す。 */
  --battle-magic-circle-hand-offset: 6px;
  --battle-magic-spell-impact-x: 82px;
  --battle-magic-spell-cast-y: -8px;
}

.battle-weapon-anchor-left {
  grid-column: 1;
}

.battle-weapon-anchor-right {
  grid-column: 3;
}

.battle-unit-art > .warrior-portrait::after {
  background: linear-gradient(180deg, rgba(13, 15, 12, 0.04), rgba(13, 15, 12, 0.24));
  box-shadow: none;
}

.battle-unit-art[class*="battle-attr-damage-"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 4;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 42%, var(--attr-damage-core), transparent 58%),
    var(--attr-damage-wash);
  box-shadow:
    inset 0 0 0 2px var(--attr-damage-line),
    inset 0 0 22px var(--attr-damage-core),
    0 0 22px var(--attr-damage-glow);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
  animation: battle-attr-damage-flash 760ms ease-out calc(var(--damage-motion-delay, 0ms) + var(--battle-impact-delay, 460ms)) both;
}

.battle-attr-damage-plain {
  --attr-damage-core: rgba(255, 255, 255, 0.42);
  --attr-damage-wash: rgba(238, 246, 255, 0.12);
  --attr-damage-line: rgba(255, 255, 255, 0.42);
  --attr-damage-glow: rgba(224, 239, 255, 0.24);
}

.battle-attr-damage-fire {
  --attr-damage-core: rgba(255, 83, 44, 0.5);
  --attr-damage-wash: rgba(255, 59, 28, 0.18);
  --attr-damage-line: rgba(255, 160, 86, 0.5);
  --attr-damage-glow: rgba(255, 77, 36, 0.36);
}

.battle-attr-damage-ice {
  --attr-damage-core: rgba(189, 236, 255, 0.5);
  --attr-damage-wash: rgba(94, 187, 255, 0.18);
  --attr-damage-line: rgba(210, 247, 255, 0.52);
  --attr-damage-glow: rgba(103, 203, 255, 0.34);
}

.battle-attr-damage-thunder {
  --attr-damage-core: rgba(255, 246, 123, 0.54);
  --attr-damage-wash: rgba(255, 220, 45, 0.2);
  --attr-damage-line: rgba(255, 249, 168, 0.56);
  --attr-damage-glow: rgba(255, 226, 50, 0.4);
}

.battle-attr-damage-water {
  --attr-damage-core: rgba(109, 209, 255, 0.48);
  --attr-damage-wash: rgba(41, 139, 255, 0.18);
  --attr-damage-line: rgba(157, 226, 255, 0.5);
  --attr-damage-glow: rgba(63, 161, 255, 0.34);
}

.battle-attr-damage-wind {
  --attr-damage-core: rgba(169, 255, 188, 0.48);
  --attr-damage-wash: rgba(75, 211, 132, 0.16);
  --attr-damage-line: rgba(186, 255, 202, 0.5);
  --attr-damage-glow: rgba(73, 220, 131, 0.32);
}

.battle-attr-damage-ground {
  --attr-damage-core: rgba(226, 184, 103, 0.5);
  --attr-damage-wash: rgba(164, 116, 53, 0.2);
  --attr-damage-line: rgba(240, 203, 132, 0.5);
  --attr-damage-glow: rgba(197, 139, 62, 0.34);
}

.battle-attr-damage-light {
  --attr-damage-core: rgba(255, 248, 184, 0.52);
  --attr-damage-wash: rgba(255, 238, 122, 0.18);
  --attr-damage-line: rgba(255, 252, 210, 0.54);
  --attr-damage-glow: rgba(255, 239, 134, 0.36);
}

.battle-attr-damage-dark {
  --attr-damage-core: rgba(150, 111, 224, 0.5);
  --attr-damage-wash: rgba(73, 50, 137, 0.22);
  --attr-damage-line: rgba(189, 158, 255, 0.52);
  --attr-damage-glow: rgba(129, 92, 221, 0.36);
}

.battle-avatar-target {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(220, 107, 87, 0.6);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(220, 107, 87, 0.22), transparent 68%),
    rgba(13, 15, 12, 0.86);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.36),
    0 0 0 1px rgba(220, 107, 87, 0.16);
  overflow: hidden;
}

.battle-avatar-target img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: lighten;
}

.battle-avatar-target span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  padding: 3px 5px;
  border-radius: 999px;
  background: rgba(11, 13, 10, 0.72);
  color: #ffe2d9;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
}

.battle-card-name {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  z-index: 2;
  display: block;
  padding: 4px 5px;
  border-radius: 5px;
  overflow: visible;
  background: rgba(11, 13, 10, 0.72);
  color: #fff6d7;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
}

.battle-card-name-tail {
  display: inline-block;
  padding-left: 0.55em;
}

.battle-weapon-card {
  position: absolute;
  z-index: 8;
  bottom: 28px;
  display: block;
  width: 54px;
  aspect-ratio: 2 / 3;
  border: 1px solid rgba(231, 237, 255, 0.58);
  border-left: 5px solid var(--weapon);
  border-radius: 6px;
  background-image:
    linear-gradient(180deg, rgba(13, 15, 12, 0.02), rgba(13, 15, 12, 0.16)),
    linear-gradient(var(--weapon-attr-tint), var(--weapon-attr-tint)),
    var(--weapon-art-back);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.48),
    0 0 16px rgba(255, 241, 184, 0.14);
}

.battle-weapon-card.has-card-art {
  bottom: 16px;
  width: 90px;
  height: 130px;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  filter:
    drop-shadow(0 12px 10px rgba(0, 0, 0, 0.56))
    drop-shadow(0 0 11px rgba(255, 234, 164, 0.3));
}

.battle-weapon-art {
  position: absolute;
  inset: 0;
  background-image: var(--battle-weapon-art, var(--card-art));
  background-position: center;
  background-size: 108% auto;
  background-repeat: no-repeat;
  transform: var(--battle-weapon-art-adjustment, none);
}

.battle-weapon-right .battle-weapon-art {
  transform: scaleX(-1) var(--battle-weapon-art-adjustment, scale(1));
}

.battle-weapon-card:is(
  [data-battle-weapon-art$="/00_41.webp"],
  [data-battle-weapon-art$="/00_42.webp"],
  [data-battle-weapon-art$="/00_44.webp"],
  [data-battle-weapon-art$="/00_48.webp"],
  [data-battle-weapon-art$="/00_49.webp"],
  [data-battle-weapon-art$="/00_50.webp"],
  [data-battle-weapon-art$="/00_52.webp"],
  [data-battle-weapon-art$="/00_58.webp"],
  [data-battle-weapon-art$="/01_38.webp"],
  [data-battle-weapon-art$="/01_44.webp"],
  [data-battle-weapon-art$="/01_51.webp"],
  [data-battle-weapon-art$="/02_42.webp"],
  [data-battle-weapon-art$="/02_43.webp"],
  [data-battle-weapon-art$="/02_49.webp"],
  [data-battle-weapon-art$="/S1_04.webp"]
) {
  container-type: inline-size;
  /* 幅108%・縦横比3:2の絵で、元絵の握り位置を支点にする。 */
  --battle-weapon-grip-x: calc((var(--battle-weapon-art-grip-x) - 0.5) * 108cqw);
  --battle-weapon-grip-y: calc((var(--battle-weapon-art-grip-y) - 0.5) * 162cqw);
  --battle-weapon-art-adjustment:
    translate(var(--battle-weapon-grip-x), var(--battle-weapon-grip-y))
    rotate(var(--battle-weapon-art-tilt, 0deg)) scale(var(--battle-weapon-art-scale, 1))
    translate(calc(-1 * var(--battle-weapon-grip-x)), calc(-1 * var(--battle-weapon-grip-y)));
}

.battle-weapon-card[data-battle-weapon-art$="/00_41.webp"] {
  --battle-weapon-art-grip-x: 0.225;
  --battle-weapon-art-grip-y: 0.638;
  --battle-weapon-art-tilt: -6deg;
}

.battle-weapon-card[data-battle-weapon-art$="/00_42.webp"] {
  --battle-weapon-art-grip-x: 0.234;
  --battle-weapon-art-grip-y: 0.755;
  --battle-weapon-art-tilt: 2deg;
  --battle-weapon-art-scale: 0.92;
}

.battle-weapon-card[data-battle-weapon-art$="/00_44.webp"] {
  --battle-weapon-art-grip-x: 0.246;
  --battle-weapon-art-grip-y: 0.677;
  --battle-weapon-art-tilt: -5deg;
}

.battle-weapon-card[data-battle-weapon-art$="/00_48.webp"] {
  --battle-weapon-art-grip-x: 0.341;
  --battle-weapon-art-grip-y: 0.632;
  --battle-weapon-art-tilt: 4deg;
}

.battle-weapon-card[data-battle-weapon-art$="/00_49.webp"] {
  --battle-weapon-art-grip-x: 0.246;
  --battle-weapon-art-grip-y: 0.638;
  --battle-weapon-art-tilt: -2deg;
}

.battle-weapon-card[data-battle-weapon-art$="/00_50.webp"] {
  --battle-weapon-art-grip-x: 0.248;
  --battle-weapon-art-grip-y: 0.698;
  --battle-weapon-art-tilt: 2deg;
  --battle-weapon-art-scale: 0.95;
}

.battle-weapon-card[data-battle-weapon-art$="/00_52.webp"] {
  --battle-weapon-art-grip-x: 0.313;
  --battle-weapon-art-grip-y: 0.688;
  --battle-weapon-art-tilt: -2deg;
}

.battle-weapon-card[data-battle-weapon-art$="/00_58.webp"] {
  --battle-weapon-art-grip-x: 0.291;
  --battle-weapon-art-grip-y: 0.682;
  --battle-weapon-art-scale: 0.94;
}

.battle-weapon-card[data-battle-weapon-art$="/01_38.webp"] {
  --battle-weapon-art-grip-x: 0.225;
  --battle-weapon-art-grip-y: 0.622;
  --battle-weapon-art-tilt: -4deg;
}

.battle-weapon-card[data-battle-weapon-art$="/01_44.webp"] {
  --battle-weapon-art-grip-x: 0.27;
  --battle-weapon-art-grip-y: 0.68;
  --battle-weapon-art-tilt: 4deg;
}

.battle-weapon-card[data-battle-weapon-art$="/01_51.webp"] {
  --battle-weapon-art-grip-x: 0.403;
  --battle-weapon-art-grip-y: 0.487;
  --battle-weapon-art-tilt: -7deg;
}

.battle-weapon-card[data-battle-weapon-art$="/02_42.webp"] {
  --battle-weapon-art-grip-x: 0.332;
  --battle-weapon-art-grip-y: 0.698;
  --battle-weapon-art-tilt: 6deg;
}

.battle-weapon-card[data-battle-weapon-art$="/02_43.webp"] {
  --battle-weapon-art-grip-x: 0.345;
  --battle-weapon-art-grip-y: 0.68;
  --battle-weapon-art-tilt: 6deg;
}

.battle-weapon-card[data-battle-weapon-art$="/02_49.webp"] {
  --battle-weapon-art-grip-x: 0.3;
  --battle-weapon-art-grip-y: 0.69;
  --battle-weapon-art-tilt: 7deg;
}

.battle-weapon-card[data-battle-weapon-art$="/S1_04.webp"] {
  --battle-weapon-art-grip-x: 0.278;
  --battle-weapon-art-grip-y: 0.702;
  --battle-weapon-art-tilt: 8deg;
}

.battle-weapon-card.has-card-art::after {
  content: "";
  position: absolute;
  inset: 31% 22%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 166, 0.34), transparent 68%);
  filter: blur(2px);
}

.battle-weapon-card.battle-weapon-magic.has-card-art {
  filter:
    drop-shadow(0 12px 10px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 14px rgba(178, 158, 255, 0.42));
}

.battle-weapon-card.battle-weapon-magic.has-card-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.battle-weapon-card.battle-magic-book.has-card-art {
  bottom: 20px;
  width: 84px;
  height: 118px;
}

.battle-weapon-card.battle-magic-book.has-card-art::before {
  inset: 23% 19%;
  background: radial-gradient(circle, rgba(255, 245, 174, 0.24), rgba(146, 120, 255, 0.2) 52%, transparent 74%);
  filter: blur(2px);
}

.battle-magic-circle {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 70%;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  background-image: url("../assets/effects/battle/magic_circle.webp");
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  filter:
    brightness(1.22)
    saturate(1.16)
    drop-shadow(0 0 9px rgba(205, 230, 255, 0.72))
    drop-shadow(0 0 18px rgba(137, 136, 255, 0.42));
}

.battle-magic-circle-book {
  z-index: 12;
}

.battle-magic-circle-spell {
  --battle-magic-circle-flip: 1;
  --battle-magic-circle-spin-end: 360deg;
  --battle-magic-circle-scale: 0.84;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  opacity: 0;
}

.battle-magic-circle-left.battle-magic-circle-book,
.battle-magic-circle-left.battle-magic-circle-spell {
  left: calc(100% + var(--battle-magic-circle-hand-offset));
}

.battle-magic-circle-right.battle-magic-circle-book,
.battle-magic-circle-right.battle-magic-circle-spell {
  /* 右側の魔法陣だけを反転表示する。直接魔法イラスト本体は反転させない。 */
  --battle-magic-circle-flip: -1;
  --battle-magic-circle-spin-end: -360deg;
  left: calc(0% - var(--battle-magic-circle-hand-offset));
}

.battle-magic-circle-book::after {
  content: "";
  position: absolute;
  top: 47%;
  left: 58%;
  width: 86px;
  height: 10px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 0 50%, rgba(255, 255, 255, 0.92), rgba(193, 224, 255, 0.45) 34%, transparent 72%),
    linear-gradient(90deg, rgba(209, 234, 255, 0.85), rgba(146, 166, 255, 0.42), transparent);
  box-shadow:
    0 0 14px rgba(198, 226, 255, 0.74),
    0 0 26px rgba(133, 119, 255, 0.42);
  opacity: 0;
  transform: scaleX(0.18);
  transform-origin: left center;
  pointer-events: none;
}

.weapon-special-fire .battle-magic-circle,
.battle-magic-circle.weapon-special-fire {
  filter:
    hue-rotate(122deg)
    saturate(1.55)
    brightness(1.18)
    drop-shadow(0 0 10px rgba(255, 134, 88, 0.72));
}

.weapon-special-ice .battle-magic-circle,
.weapon-special-water .battle-magic-circle,
.battle-magic-circle.weapon-special-ice,
.battle-magic-circle.weapon-special-water {
  filter:
    brightness(1.25)
    saturate(1.35)
    drop-shadow(0 0 10px rgba(142, 221, 255, 0.78));
}

.weapon-special-thunder .battle-magic-circle,
.weapon-special-light .battle-magic-circle,
.battle-magic-circle.weapon-special-thunder,
.battle-magic-circle.weapon-special-light {
  filter:
    hue-rotate(36deg)
    saturate(1.35)
    brightness(1.34)
    drop-shadow(0 0 11px rgba(255, 236, 143, 0.8));
}

.weapon-special-wind .battle-magic-circle,
.weapon-special-ground .battle-magic-circle,
.battle-magic-circle.weapon-special-wind,
.battle-magic-circle.weapon-special-ground {
  filter:
    hue-rotate(72deg)
    saturate(1.35)
    brightness(1.2)
    drop-shadow(0 0 10px rgba(143, 240, 177, 0.64));
}

.weapon-special-dark .battle-magic-circle,
.battle-magic-circle.weapon-special-dark {
  filter:
    hue-rotate(250deg)
    saturate(1.4)
    brightness(0.92)
    drop-shadow(0 0 12px rgba(153, 105, 255, 0.72));
}

.battle-weapon-card.battle-magic-spell.has-card-art {
  bottom: 8px;
  width: 112px;
  height: 136px;
}

.battle-magic-spell .battle-weapon-art {
  z-index: 3;
  background-size: 108% auto;
  filter: brightness(1.1) saturate(1.22) contrast(1.04);
  mix-blend-mode: screen;
  transform-origin: 50% 50%;
}

.battle-weapon-right.battle-magic-spell .battle-weapon-art {
  transform: none;
}

.battle-weapon-card.battle-magic-spell.has-card-art::before,
.battle-weapon-card.battle-magic-spell.has-card-art::after {
  display: none;
}

.battle-magic-circle-spell::before {
  content: "";
  position: absolute;
  inset: 4% 0;
  z-index: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.36), transparent 25%),
    radial-gradient(circle at 50% 48%, rgba(116, 178, 255, 0.36), rgba(161, 112, 255, 0.16) 50%, transparent 76%);
  filter: blur(5px);
  pointer-events: none;
  animation: battle-magic-aura 1900ms ease-out both;
}

.battle-magic-circle-spell::after {
  content: "";
  position: absolute;
  inset: 23% 18%;
  z-index: 2;
  border: 1px solid rgba(225, 238, 255, 0.8);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.36), transparent 30%),
    radial-gradient(circle, rgba(146, 192, 255, 0.24), transparent 68%);
  box-shadow:
    0 0 18px rgba(158, 194, 255, 0.68),
    0 0 34px rgba(142, 96, 255, 0.32),
    inset 0 0 14px rgba(255, 255, 255, 0.44);
  filter: none;
  pointer-events: none;
  animation: battle-magic-shock-ring 1900ms ease-out both;
}

.battle-weapon-left {
  right: -20px;
  transform-origin: 30% 72%;
  transform: translate(-16px, 6px) rotate(-6deg);
  animation: battle-weapon-attack 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.battle-weapon-right {
  left: -16px;
  transform-origin: 70% 72%;
  transform: translate(20px, 6px) scaleX(-1) rotate(-6deg);
  animation: battle-weapon-defense 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.battle-weapon-left.has-card-art {
  right: -50px;
  transform-origin: 32% 72%;
}

.battle-weapon-right.has-card-art {
  left: -50px;
  transform-origin: 68% 72%;
}

.battle-weapon-left.weapon-broken {
  animation:
    battle-weapon-attack 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.weapon-broken {
  animation:
    battle-weapon-defense 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-left.weapon-returned,
.battle-weapon-right.weapon-returned {
  animation: battle-weapon-effect-return 720ms ease-in both;
}

.battle-weapon-left.battle-weapon-kind-pierce {
  transform: translate(-12px, 5px) rotate(0deg);
  animation: battle-weapon-pierce-left 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.battle-weapon-right.battle-weapon-kind-pierce {
  transform: translate(16px, 5px) scaleX(-1) rotate(0deg);
  animation: battle-weapon-pierce-right 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.battle-weapon-left.battle-weapon-kind-blow {
  transform: translate(-14px, 4px) rotate(-4deg);
  animation: battle-weapon-blow-left 1900ms cubic-bezier(0.16, 0.88, 0.22, 1) both;
}

.battle-weapon-right.battle-weapon-kind-blow {
  transform: translate(18px, 4px) scaleX(-1) rotate(-4deg);
  animation: battle-weapon-blow-right 1900ms cubic-bezier(0.16, 0.88, 0.22, 1) both;
}

.battle-weapon-left.battle-weapon-kind-arrow {
  transform: translate(-10px, 4px) rotate(-6deg);
  animation: battle-weapon-arrow-left 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-kind-arrow {
  transform: translate(14px, 4px) scaleX(-1) rotate(-6deg);
  animation: battle-weapon-arrow-right 1900ms ease-out both;
}

.battle-weapon-left.battle-weapon-kind-pierce.weapon-broken {
  animation:
    battle-weapon-pierce-left 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-kind-pierce.weapon-broken {
  animation:
    battle-weapon-pierce-right 1900ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-left.battle-weapon-kind-blow.weapon-broken {
  animation:
    battle-weapon-blow-left 1900ms cubic-bezier(0.16, 0.88, 0.22, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-kind-blow.weapon-broken {
  animation:
    battle-weapon-blow-right 1900ms cubic-bezier(0.16, 0.88, 0.22, 1) both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-left.battle-weapon-kind-arrow.weapon-broken {
  animation:
    battle-weapon-arrow-left 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-kind-arrow.weapon-broken {
  animation:
    battle-weapon-arrow-right 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-left.battle-weapon-guard {
  transform: translate(-4px, 4px) rotate(-2deg);
  animation: battle-weapon-guard-left 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-guard {
  z-index: 6;
  transform: translate(8px, 4px) scaleX(-1) rotate(-2deg);
  animation: battle-weapon-guard-right 1900ms ease-out both;
}

.battle-weapon-left.battle-weapon-guard.battle-weapon-guard-glow {
  animation: battle-weapon-guard-left 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-guard.battle-weapon-guard-glow {
  animation: battle-weapon-guard-right 1900ms ease-out both;
}

.battle-weapon-guard-glow .battle-weapon-art {
  animation: battle-weapon-guard-art-glow 900ms ease-out calc(var(--damage-motion-delay, 0ms) + 470ms) both;
}

.battle-weapon-left.battle-weapon-guard.weapon-broken {
  animation:
    battle-weapon-guard-left 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.battle-weapon-guard.weapon-broken {
  animation:
    battle-weapon-guard-right 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-left.battle-magic-book {
  transform: translate(-4px, 4px) rotate(-1deg);
  animation: battle-magic-book-cast-left 1900ms ease-out both;
}

.battle-weapon-right.battle-magic-book {
  z-index: 6;
  transform: translate(8px, 4px) rotate(-1deg);
  animation: battle-magic-book-cast-right 1900ms ease-out both;
}

.battle-weapon-left.battle-magic-book.weapon-broken {
  animation:
    battle-magic-book-cast-left 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-weapon-right.battle-magic-book.weapon-broken {
  animation:
    battle-magic-book-cast-right 1900ms ease-out both,
    battle-weapon-break-fade 1900ms ease-out both;
}

.battle-result:not(.battle-process-only) .battle-magic-circle-book {
  animation: battle-magic-circle-cast 1900ms ease-out both;
  animation-delay: var(--damage-motion-delay, 0ms);
}

.battle-result:not(.battle-process-only) .battle-magic-circle-book::after {
  animation: battle-magic-book-ray 1900ms ease-out both;
  animation-delay: var(--damage-motion-delay, 0ms);
}

.battle-weapon-left.battle-magic-spell {
  --battle-magic-spell-x: var(--battle-magic-spell-impact-x);
  --battle-magic-spell-entry-x: -14px;
  transform-origin: 50% 50%;
  transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(0.96);
  animation: battle-magic-spell-cast 1900ms cubic-bezier(0.18, 0.88, 0.24, 1) both;
}

.battle-weapon-right.battle-magic-spell {
  --battle-magic-spell-x: calc(var(--battle-magic-spell-impact-x) * -1);
  --battle-magic-spell-entry-x: 14px;
  transform-origin: 50% 50%;
  transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(0.96);
  animation: battle-magic-spell-cast 1900ms cubic-bezier(0.18, 0.88, 0.24, 1) both;
}

.battle-weapon-left.battle-magic-spell.has-card-art {
  right: -60px;
}

.battle-weapon-right.battle-magic-spell.has-card-art {
  left: -60px;
}

.battle-weapon-left.battle-magic-spell.weapon-broken {
  animation: battle-magic-spell-break 1900ms cubic-bezier(0.18, 0.88, 0.24, 1) both;
}

.battle-weapon-right.battle-magic-spell.weapon-broken {
  animation: battle-magic-spell-break 1900ms cubic-bezier(0.18, 0.88, 0.24, 1) both;
}

/*
 * 戦闘処理中は後段の武器種別animation shorthandより、構えの経過位置を優先する。
 * 特殊処理で武器表示だけ更新されても、盾などが最初から構え直さないようにする。
 */
.battle-result.battle-process-only .battle-weapon-card:not(.battle-magic-spell):not(.weapon-broken):not(.weapon-returned) {
  animation-duration: var(--battle-weapon-ready-ms, 1900ms);
  animation-timing-function: cubic-bezier(0.18, 0.9, 0.24, 1);
  animation-delay: var(--battle-weapon-ready-delay, 0ms);
  animation-fill-mode: both;
}

.battle-weapon-left.battle-magic-book.weapon-returned,
.battle-weapon-right.battle-magic-book.weapon-returned,
.battle-weapon-left.battle-magic-spell.weapon-returned,
.battle-weapon-right.battle-magic-spell.weapon-returned {
  animation: battle-weapon-effect-return-magic 720ms ease-in both;
}

.weapon-fragment {
  position: absolute;
  top: 47%;
  left: 48%;
  z-index: 14;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: rgba(255, 238, 186, 0.94);
  box-shadow: 0 0 9px rgba(255, 221, 129, 0.72);
  opacity: 0;
  pointer-events: none;
}

.fragment-a {
  animation: weapon-fragment-a 1900ms ease-out both;
}

.fragment-b {
  width: 7px;
  height: 12px;
  background: rgba(225, 238, 255, 0.9);
  animation: weapon-fragment-b 1900ms ease-out both;
}

.fragment-c {
  width: 12px;
  height: 6px;
  background: rgba(255, 196, 151, 0.9);
  animation: weapon-fragment-c 1900ms ease-out both;
}

.battle-weapon-break {
  position: absolute;
  top: 17px;
  z-index: 16;
  padding: 3px 7px;
  border: 1px solid rgba(255, 224, 136, 0.72);
  border-radius: 999px;
  background: rgba(102, 34, 27, 0.86);
  color: #ffe19a;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 0 16px rgba(220, 107, 87, 0.3);
  animation: weapon-break-label 1900ms ease-out both;
}

.battle-process-weapon-loss,
.battle-process-weapon-loss-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.battle-process-weapon-loss-art {
  animation: battle-process-weapon-loss 650ms ease-out both;
  animation-delay: var(--weapon-effect-break-delay);
}

.battle-process-weapon-loss.is-returned .battle-process-weapon-loss-art {
  transform-origin: center bottom;
  animation-name: battle-process-weapon-return;
}

.battle-process-weapon-loss.is-returned .battle-process-weapon-loss-label,
.battle-process-effect-return {
  color: #d4f5ff;
  border-color: #a9eaff;
  background: rgba(22, 77, 103, 0.94);
}

.battle-process-effect-return {
  display: inline-block;
  border: 1px solid #a9eaff;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 1em;
}

.battle-process-weapon-loss-flash {
  position: absolute;
  inset: 20% 5%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff9df, rgba(255, 166, 80, 0.8) 20%, transparent 65%);
  animation: battle-process-weapon-flash 650ms ease-out both;
  animation-delay: var(--weapon-effect-break-delay);
}

.battle-process-weapon-loss-label {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  white-space: nowrap;
  padding: 4px 8px;
  border: 1px solid #ffe19a;
  border-radius: 999px;
  background: rgba(102, 34, 27, 0.94);
  color: #ffe19a;
  font-size: 12px;
  font-weight: 900;
  animation: battle-process-weapon-flash 1200ms ease-out both;
  animation-delay: var(--weapon-effect-break-delay);
}

.battle-process-weapon-fragment {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 12px;
  background: #fff0bd;
  box-shadow: 0 0 8px #ffc478;
  animation: battle-process-weapon-fragment 650ms ease-out both;
  animation-delay: var(--weapon-effect-break-delay);
  --fragment-x: -42px;
  --fragment-y: -28px;
}

.battle-process-weapon-fragment.fragment-b { --fragment-x: 40px; --fragment-y: -20px; }
.battle-process-weapon-fragment.fragment-c { --fragment-x: 12px; --fragment-y: 48px; }

@keyframes battle-process-weapon-loss {
  0% { opacity: 1; filter: brightness(1); }
  18% { opacity: 1; filter: brightness(3); }
  100% { opacity: 0; filter: brightness(1.5) blur(3px); }
}

@keyframes battle-process-weapon-return {
  0% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
  24% { opacity: 1; transform: translateY(-5px) scale(1.04); filter: brightness(1.6) drop-shadow(0 0 12px #9feaff); }
  100% { opacity: 0; transform: translateY(32px) scale(0.45); filter: brightness(1.2); }
}

@keyframes battle-process-weapon-flash {
  0% { opacity: 0; }
  16%, 45% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes battle-process-weapon-fragment {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--fragment-x), var(--fragment-y)) rotate(150deg); }
}

.battle-weapon-durability {
  position: absolute;
  top: 17px;
  z-index: 16;
  padding: 3px 7px;
  border: 1px solid rgba(164, 224, 255, 0.8);
  border-radius: 999px;
  background: rgba(28, 61, 89, 0.88);
  color: #d9f3ff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 0 18px rgba(92, 184, 255, 0.28);
  animation: weapon-durability-label 1900ms ease-out both;
}

.battle-weapon-break-left {
  right: -44px;
}

.battle-weapon-break-right {
  left: -44px;
}

.battle-weapon-durability-left {
  right: -30px;
}

.battle-weapon-durability-right {
  left: -30px;
}

.battle-no-weapon {
  position: absolute;
  z-index: 3;
  bottom: 42px;
  padding: 3px 6px;
  border: 1px solid rgba(242, 219, 157, 0.46);
  border-radius: 999px;
  background: rgba(18, 20, 17, 0.82);
  color: #eadfb6;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.battle-no-weapon-left {
  right: -10px;
  transform: translateX(-8px);
  animation: battle-no-weapon-attack 1300ms ease-out both;
}

.battle-no-weapon-right {
  left: -10px;
  transform: translateX(8px);
  animation: battle-no-weapon-defense 1300ms ease-out both;
}

.battle-weapon-name {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app:is(.mobile-layout, .mobile-landscape-layout):lang(en) :is(.battle-card-name, .battle-weapon-name) {
  overflow-wrap: anywhere;
}

#app:is(.mobile-layout, .mobile-landscape-layout):lang(en) .battle-weapon-name {
  overflow: visible;
  white-space: normal;
}

@media (max-width: 620px) and (orientation: portrait),
  (max-width: 900px) and (max-height: 620px) and (orientation: landscape) {
  #app:is(.mobile-layout, .mobile-landscape-layout):lang(en) .battle-actor {
    z-index: auto;
    container-type: inline-size;
  }

  /* 長い名前はイラストの下端で、戦士に割り当てた列の幅を使う。 */
  #app:is(.mobile-layout, .mobile-landscape-layout):lang(en) .battle-card-name {
    left: 50%;
    right: auto;
    z-index: 21;
    width: min(100cqw, 144px);
    translate: -50% 0;
  }

  @container (max-width: 70px) {
    #app.mobile-landscape-layout:lang(en) .battle-unit-art > .battle-commander-badge {
      padding: 1px;
      font-size: clamp(7px, 14.5cqw, 9px);
    }
  }
}

@media (max-width: 640px) and (orientation: landscape) {
  #app.mobile-landscape-layout:lang(en) .battle-card-name {
    width: min(calc(100cqw + 6px), 144px);
    padding-inline: 0;
    font-size: 9px;
    text-wrap: balance;
  }

  /* 名前欄を外側に広げ、中央の戦闘表示から離す。 */
  #app.mobile-landscape-layout:lang(en) .battle-side-left .battle-card-name {
    left: calc(50% - 6.5px);
  }

  #app.mobile-landscape-layout:lang(en) .battle-side-right .battle-card-name {
    left: calc(50% + 6.5px);
  }

  #app.mobile-landscape-layout:lang(en) #battlePanel
    .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) {
    --battle-head-row: calc(var(--landscape-battle-head-height) + var(--battle-heading-copy-line));
  }
}

.battle-impact-sync-marker {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  animation: battle-impact-sync-marker 1ms step-end
    calc(var(--damage-motion-delay, 0ms) + var(--battle-impact-delay, 460ms)) both;
}

.battle-impact {
  position: relative;
  z-index: 30;
  display: grid;
  place-items: center;
  min-height: 118px;
  color: #ffe19a;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 0 12px rgba(255, 225, 154, 0.44);
  pointer-events: none;
}

.battle-impact::before,
.battle-impact::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 86px;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(255, 241, 184, 0.94), transparent);
  box-shadow: 0 0 18px rgba(255, 225, 154, 0.38);
  z-index: 1;
  animation: battle-impact-flash 1500ms ease-out both;
}

.battle-impact::before {
  --impact-rotate: 36deg;
  transform: rotate(36deg);
}

.battle-impact::after {
  --impact-rotate: -36deg;
  transform: rotate(-36deg);
}

.battle-impact span {
  position: relative;
  z-index: 31;
  display: grid;
  place-items: center;
  width: var(--battle-impact-badge-size, 38px);
  height: var(--battle-impact-badge-size, 38px);
  border: 1px solid rgba(255, 225, 154, 0.56);
  border-radius: 50%;
  background: rgba(17, 19, 16, 0.86);
  animation: battle-impact-label 1500ms ease-out both;
}

/* 英語の長い結果名は中央を保ったまま、文字幅に合わせて枠を広げる。 */
:lang(en) .battle-result:not(.final-blow) .battle-impact {
  grid-template-columns: minmax(0, 1fr);
}

:lang(en) .battle-result:not(.final-blow) .battle-impact > span {
  width: max-content;
  min-width: var(--battle-impact-badge-size, 38px);
  padding-inline: 0.6em;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
}

.final-blow .battle-impact::before,
.final-blow .battle-impact::after {
  width: 6px;
  height: 122px;
  background: linear-gradient(180deg, transparent, rgba(255, 238, 171, 1), rgba(255, 111, 88, 0.92), transparent);
  box-shadow:
    0 0 22px rgba(255, 225, 154, 0.78),
    0 0 42px rgba(220, 82, 61, 0.48);
  animation-name: finish-impact-flash;
}

.final-blow .battle-impact span {
  --finish-impact-offset-x: -4px;
  width: 54px;
  height: 54px;
  border-color: rgba(255, 238, 171, 0.94);
  background: radial-gradient(circle, rgba(111, 26, 23, 0.96), rgba(17, 19, 16, 0.9));
  color: #fff0a8;
  font-size: 13px;
  box-shadow:
    0 0 0 2px rgba(255, 238, 171, 0.18),
    0 0 28px rgba(255, 225, 154, 0.56),
    0 0 48px rgba(220, 82, 61, 0.4);
  animation-name: finish-impact-label;
}

:lang(en) .final-blow .battle-impact {
  grid-template-columns: minmax(0, 1fr);
}

:lang(en) .final-blow .battle-impact > span {
  --finish-impact-offset-x: 0px;
  text-align: center;
}

.battle-side-left .battle-unit-art {
  --unit-start-x: -8px;
  transform: translateX(-8px) scale(0.98);
  animation: battle-unit-attack 1900ms ease-out both;
}

.battle-side-right .battle-unit-art {
  --unit-start-x: 8px;
  transform: translateX(8px) scale(0.98);
  animation: battle-unit-defense 1900ms ease-out both;
}

.attack-win .battle-role-attack .battle-unit-art,
.defense-win .battle-role-defense .battle-unit-art {
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.36),
    0 0 0 1px rgba(255, 225, 154, 0.24),
    0 0 22px rgba(255, 225, 154, 0.2);
}

.attack-win .battle-role-attack .battle-unit-art::before,
.defense-win .battle-role-defense .battle-unit-art::before,
.direct-attack .battle-role-attack .battle-unit-art::before {
  animation: battle-winner-glint 1300ms ease-out var(--damage-motion-delay, 0ms) both;
}

.attack-win .battle-role-defense .battle-unit-art,
.defense-win .battle-role-attack .battle-unit-art {
  animation-name: battle-unit-hit;
  filter: saturate(0.82) brightness(0.92);
}

.attack-win .battle-role-defense .battle-unit-art.battle-unit-defeated {
  animation-name: battle-unit-defeat;
  animation-duration: 1900ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
  filter: saturate(0.65) brightness(0.78);
}

.final-blow.attack-win .battle-role-defense .battle-unit-art.battle-unit-defeated {
  animation-name: battle-unit-finish-defeat;
  animation-duration: 1900ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
  filter: saturate(0.5) brightness(0.7);
}

.draw .battle-impact span {
  color: #dfe7ff;
  border-color: rgba(223, 231, 255, 0.58);
}

.battle-interrupt .battle-impact span {
  color: #ffd79a;
  border-color: rgba(255, 190, 118, 0.72);
  background: rgba(54, 30, 22, 0.92);
}

.battle-interrupt .battle-unit-art.battle-unit-defeated {
  animation-name: battle-unit-defeat;
  animation-duration: 2300ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
  filter: saturate(0.65) brightness(0.78);
}

/* 戦闘結果表示後の反射ダメージなどは、着弾済みの戦闘モーションを再開せず戦士だけ退場させる。 */
.battle-result .battle-unit-art.battle-unit-effect-defeated {
  animation-name: battle-unit-defeat !important;
  animation-duration: 1180ms !important;
  animation-timing-function: ease-out !important;
  animation-delay: 0ms !important;
  animation-fill-mode: both !important;
  filter: saturate(0.65) brightness(0.78);
}

.direct-attack .battle-role-attack .battle-unit-art {
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.36),
    0 0 0 1px rgba(255, 225, 154, 0.28),
    0 0 24px rgba(255, 225, 154, 0.22);
}

.direct-attack .battle-role-direct-target .battle-avatar-target {
  animation: direct-avatar-hit 1900ms ease-out both;
  filter: saturate(0.82) brightness(0.92);
}

.direct-attack .battle-impact span {
  color: #ffc4b8;
  border-color: rgba(220, 107, 87, 0.72);
  background: rgba(49, 20, 18, 0.9);
}

/* 合計計算とダメージ計算時スタックの表示後に、攻撃モーションだけを開始する。 */
.battle-result:not(.battle-process-only) .battle-unit-art,
.battle-result:not(.battle-process-only) .battle-avatar-target,
.battle-result:not(.battle-process-only) .battle-weapon-card,
.battle-result:not(.battle-process-only) .battle-magic-spell::before,
.battle-result:not(.battle-process-only) .battle-magic-spell::after,
.battle-result:not(.battle-process-only) .battle-magic-circle,
.battle-result:not(.battle-process-only) .battle-magic-circle::after,
.battle-result:not(.battle-process-only) .battle-no-weapon,
.battle-result:not(.battle-process-only) .weapon-fragment,
.battle-result:not(.battle-process-only) .battle-weapon-break,
.battle-result:not(.battle-process-only) .battle-weapon-durability,
.battle-result:not(.battle-process-only) .battle-impact::before,
.battle-result:not(.battle-process-only) .battle-impact::after,
.battle-result:not(.battle-process-only) .battle-impact span {
  animation-delay: var(--damage-motion-delay, 0ms);
}

/*
 * 武器の振り始めと着弾VFXを別々のdelayで合わせず、実DOMの着弾イベントを共通起点にする。
 * controllerがmarkerのanimationstartを受けてbattle-impact-activeを付けるまで、着弾側だけ停止する。
 */
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-attribute-impact-ring,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-attribute-image-effect,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-attribute-image-effect::after,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-weapon-guard-glow .battle-weapon-art,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-impact::before,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-impact::after,
.battle-result.battle-impact-synced:not(.battle-process-only) .battle-impact span,
.battle-result.battle-impact-synced:not(.battle-process-only) .clash-damage {
  animation-delay: 0ms !important;
}

.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-attribute-impact-ring,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-attribute-image-effect,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-attribute-image-effect::after,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-weapon-guard-glow .battle-weapon-art,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-impact::before,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-impact::after,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .battle-impact span,
.battle-result.battle-impact-synced:not(.battle-impact-active):not(.battle-process-only) .clash-damage {
  animation-play-state: paused !important;
}

/* ダメージ計算特殊ウェイト中は、合計バーだけを見せて戦闘モーションはまだ走らせない。 */
.battle-result.battle-motion-paused .battle-unit-art,
.battle-result.battle-motion-paused .battle-avatar-target,
.battle-result.battle-motion-paused .battle-weapon-card,
.battle-result.battle-motion-paused .battle-magic-spell::before,
.battle-result.battle-motion-paused .battle-magic-spell::after,
.battle-result.battle-motion-paused .battle-magic-circle:not(.battle-magic-circle-spell),
.battle-result.battle-motion-paused .battle-magic-circle::after,
.battle-result.battle-motion-paused .battle-no-weapon,
.battle-result.battle-motion-paused .weapon-fragment,
.battle-result.battle-motion-paused .battle-weapon-break,
.battle-result.battle-motion-paused .battle-weapon-durability,
.battle-result.battle-motion-paused .battle-impact::before,
.battle-result.battle-motion-paused .battle-impact::after,
.battle-result.battle-motion-paused .battle-impact span {
  animation: none !important;
}

/* 構えから段階計算へDOMが切り替わっても、武器は攻撃モーションの開始位置を保つ。 */
.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left {
  opacity: 1;
  transform: translate(-8px, 2px) rotate(-2deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right {
  opacity: 1;
  transform: translate(8px, 2px) rotate(2deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-weapon-kind-pierce {
  transform: translate(-8px, 4px) rotate(42deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-weapon-kind-pierce {
  transform: translate(12px, 4px) rotate(-42deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-weapon-kind-blow {
  transform: translate(-8px, -16px) rotate(-42deg) scale(1.02);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-weapon-kind-blow {
  transform: translate(12px, -16px) rotate(42deg) scale(1.02);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-weapon-kind-arrow {
  transform: translate(-10px, 0) rotate(-42deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-weapon-kind-arrow {
  transform: translate(14px, 0) rotate(42deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-weapon-guard,
.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-magic-book {
  transform: translate(0, 0) rotate(0deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-weapon-guard,
.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-magic-book {
  transform: translate(4px, 0) rotate(0deg) scale(1);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-left.battle-magic-spell {
  transform: translate(var(--battle-magic-spell-impact-x), var(--battle-magic-spell-cast-y)) scale(0.9);
}

.battle-result.damage-calc-staged.battle-motion-paused .battle-weapon-right.battle-magic-spell {
  transform: translate(calc(var(--battle-magic-spell-impact-x) * -1), var(--battle-magic-spell-cast-y)) scale(0.9);
}

/* 直接魔法は段階計算中も魔法陣だけを残し、詠唱カードの再出現・消失を挟まない。 */
.battle-result.damage-calc-staged.battle-motion-paused .battle-magic-spell .battle-weapon-art,
.battle-result.damage-calc-staged.battle-motion-paused .battle-magic-spell::before,
.battle-result.damage-calc-staged.battle-motion-paused .battle-magic-spell::after {
  opacity: 0;
}

/* 直接魔法の魔法陣は、処理中からダメージ計算終了まで同じ位置で回し続ける。 */
.battle-result .battle-magic-circle-spell {
  --battle-magic-circle-opacity: 0.5;
  opacity: var(--battle-magic-circle-opacity);
  transform-origin: 50% 50%;
  animation: battle-magic-circle-spin 4200ms linear infinite;
  animation-delay: 0ms;
  animation-play-state: running;
}

.battle-result:not(.battle-process-only) .battle-magic-circle-spell {
  animation:
    battle-magic-circle-spin 4200ms linear infinite,
    battle-magic-circle-fade-out var(--weapon-return-ms, 720ms) ease-in both;
  animation-delay:
    0ms,
    var(--weapon-return-delay, calc(var(--damage-motion-delay, 0ms) + 2680ms));
}

.battle-result:not(.battle-process-only) .battle-magic-circle-spell.magic-circle-broken {
  animation:
    battle-magic-circle-spin 4200ms linear infinite,
    battle-magic-circle-break-fade 1900ms ease-out both;
  animation-delay:
    0ms,
    var(--damage-motion-delay, 0ms);
}

/* 処理中に魔法が失われた場合も、詠唱元の魔法陣を同じタイミングで閉じる。 */
.battle-result.battle-process-only .battle-magic-circle.battle-process-magic-exit {
  animation:
    battle-magic-circle-spin 4200ms linear infinite,
    battle-process-weapon-loss 650ms ease-out both;
  animation-delay: 0ms, var(--weapon-effect-break-delay);
}

.battle-result.battle-process-only .battle-magic-circle.battle-process-magic-exit.is-returned {
  animation-name: battle-magic-circle-spin, battle-magic-circle-fade-out;
}

.battle-result:not(.battle-process-only) .battle-magic-circle-spell::before,
.battle-result:not(.battle-process-only) .battle-magic-circle-spell::after {
  animation-delay: 0ms;
}

.battle-formula-grid {
  display: grid;
  gap: 5px;
}

.formula-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 7px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid #4f5748;
  border-radius: 7px;
  background: #171a17;
}

.formula-title {
  display: contents;
}

.formula-title > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formula-unit-summary {
  display: flex;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.formula-unit-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formula-unit-hp {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 3px;
  align-items: center;
}

.formula-unit-hp-value {
  display: grid;
  min-width: 34px;
  color: #f5f1df;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
}

.formula-unit-hp-value > span {
  grid-area: 1 / 1;
  transition: opacity 120ms ease-out;
}

.formula-unit-hp-before {
  opacity: 0;
}

.formula-unit-hp-after {
  opacity: 1;
}

.formula-unit-hp-track {
  display: block;
  width: 42px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.formula-unit-hp-fill {
  display: block;
  width: var(--battle-hp-after, 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--battle-hp-after-color, #65d77a);
  box-shadow: 0 0 6px color-mix(in srgb, var(--battle-hp-after-color, #65d77a) 66%, transparent);
  transition:
    width 260ms cubic-bezier(0.2, 0.74, 0.18, 1),
    background-color 150ms ease-out;
}

.battle-result.battle-hp-impact-synced:not(.battle-impact-active) .formula-unit-hp-changing .formula-unit-hp-before {
  opacity: 1;
}

.battle-result.battle-hp-impact-synced:not(.battle-impact-active) .formula-unit-hp-changing .formula-unit-hp-after {
  opacity: 0;
}

.battle-result.battle-hp-impact-synced:not(.battle-impact-active) .formula-unit-hp-changing .formula-unit-hp-fill {
  width: var(--battle-hp-before, 100%);
  background: var(--battle-hp-before-color, #65d77a);
}

.formula-title strong {
  min-width: 2ch;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

.damage-calc-number-shift {
  position: relative;
  display: inline-grid;
  min-width: 1.7ch;
  overflow: hidden;
  place-items: center;
  vertical-align: bottom;
}

/* 合計欄は通常数字と補正アニメの右端を同じ位置に固定する。 */
.formula-title .formula-total-shift {
  min-width: 2ch;
  justify-items: end;
}

.formula-title .formula-total-shift > span {
  text-align: right;
}

.damage-calc-number-before,
.damage-calc-number-after {
  grid-area: 1 / 1;
  min-width: 100%;
  text-align: center;
}

.damage-calc-number-before {
  animation: damage-calc-number-before-up 680ms cubic-bezier(0.18, 0.9, 0.24, 1) calc(var(--damage-calc-correction-start-delay, 0ms) + 150ms) both;
}

.damage-calc-number-after {
  animation: damage-calc-number-after-up 680ms cubic-bezier(0.18, 0.9, 0.24, 1) calc(var(--damage-calc-correction-start-delay, 0ms) + 150ms) both;
}

.damage-calc-number-shift.shift-down .damage-calc-number-before {
  animation-name: damage-calc-number-before-down;
}

.damage-calc-number-shift.shift-down .damage-calc-number-after {
  animation-name: damage-calc-number-after-down;
}

.formula-term.correction-up,
.formula-term.correction-down {
  animation: damage-calc-correction-term 820ms cubic-bezier(0.18, 0.9, 0.24, 1) calc(var(--damage-calc-correction-start-delay, 0ms) + 120ms) both;
}

.damage-calc-staged .formula-term {
  opacity: 0.58;
}

.damage-calc-staged .term-basic {
  animation: damage-calc-formula-stage var(--damage-calc-basic-transition, 288ms) ease-out calc(var(--damage-calc-basic-delay, 60ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .term-weapon {
  animation: damage-calc-formula-stage var(--damage-calc-weapon-transition, 317ms) ease-out calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .term-attr {
  animation: damage-calc-formula-stage var(--damage-calc-attribute-transition, 331ms) ease-out calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .term-mod {
  opacity: 0.42;
}

/* 実際に計算しない段階は式の位置だけ残し、発光やSEと同期する対象から外す。 */
.damage-calc-staged:not(.damage-calc-with-basic) .term-basic,
.damage-calc-staged:not(.damage-calc-with-weapon) .term-weapon,
.damage-calc-staged:not(.damage-calc-with-attribute) .term-attr {
  animation: none;
  opacity: 0.28;
}

.attack-formula .formula-title strong {
  color: #f5c456;
}

.defense-formula .formula-title strong {
  color: #68d0c8;
}

.formula-line {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: nowrap;
  gap: 3px;
  align-items: center;
  min-width: 0;
  /* 属性が増えても行高を変えず、入りきらない内訳は横へ送って読む。 */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.formula-line::-webkit-scrollbar {
  display: none;
}

.formula-term {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 0;
  gap: 2px;
  align-items: center;
  white-space: nowrap;
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  background: #20241f;
  color: #111310;
}

.formula-term em {
  color: rgba(17, 19, 16, 0.78);
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
}

.formula-term strong,
.formula-total {
  color: var(--text);
  font-size: 10px;
  line-height: 1;
}

.formula-term strong {
  color: #111310;
  font-weight: 900;
}

.formula-term.is-disabled {
  border-color: rgba(255, 255, 255, 0.12);
  background: #3b3f3d;
  color: #a9aeaa;
  filter: grayscale(1);
  opacity: 0.58;
}

.formula-term.is-disabled em {
  color: #d0d4cf;
}

.formula-plus,
.formula-equals {
  color: var(--muted);
  font-weight: 700;
}

.formula-plus {
  flex: 0 0 auto;
  color: rgba(242, 239, 228, 0.68);
  font-size: 9.5px;
  line-height: 1;
}

.formula-equals,
.formula-total {
  display: none;
}

.segment-basic,
.term-basic {
  --meter-main: #d64b45;
  --calc-border: rgba(255, 159, 143, 0.9);
  --calc-glow-soft: rgba(255, 112, 94, 0.26);
  --calc-glow: rgba(255, 100, 82, 0.54);
}

.segment-weapon,
.term-weapon {
  --meter-main: #347fc8;
  --calc-border: rgba(153, 208, 255, 0.92);
  --calc-glow-soft: rgba(91, 169, 244, 0.26);
  --calc-glow: rgba(74, 157, 237, 0.56);
}

.segment-attr,
.term-attr {
  --meter-main: #4fb3a9;
  --calc-border: rgba(147, 230, 220, 0.94);
  --calc-glow-soft: rgba(79, 179, 169, 0.24);
  --calc-glow: rgba(70, 199, 185, 0.52);
}

.segment-mod,
.term-mod {
  --meter-main: #875bc3;
  --calc-border: rgba(222, 187, 255, 0.92);
  --calc-glow-soft: rgba(174, 121, 235, 0.26);
  --calc-glow: rgba(161, 102, 226, 0.56);
}

.term-basic,
.term-weapon,
.term-attr,
.term-mod {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06) 38%, transparent 58%, rgba(0, 0, 0, 0.12)),
    var(--meter-main);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.term-basic,
.term-weapon,
.term-mod,
.term-basic em,
.term-weapon em,
.term-mod em,
.term-basic strong,
.term-weapon strong,
.term-mod strong {
  color: #fff8ef;
}

.term-attr,
.term-attr em,
.term-attr strong {
  color: #fff8ef;
}

.formula-term.is-disabled strong {
  color: #d0d4cf;
}

.clash-gauge {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 50px;
  contain: layout paint;
}

.clash-reversal-light {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  animation: clash-reversal-confirm var(--damage-calc-correction-duration, 1200ms) linear var(--damage-calc-correction-start-delay, 0ms) both;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 241, 177, 0.35), #fffbea 86%, #fff);
  box-shadow: inset 0 0 14px 3px #fff3bd, inset 0 2px 2px #fff, inset 0 -2px 2px #fff;
  mix-blend-mode: screen;
}

.clash-reversal-light.reversal-right {
  background: linear-gradient(270deg, rgba(167, 255, 239, 0.35), #e9fff9 86%, #fff);
  box-shadow: inset 0 0 14px 3px #b6fff0, inset 0 2px 2px #fff, inset 0 -2px 2px #fff;
}

.reversal-feedback-disabled .clash-reversal-light { display: none; }

.clash-stage-fill > .clash-reversal-light {
  animation-name: clash-reversal-stage;
  animation-duration: inherit;
  animation-delay: inherit;
}

@keyframes clash-reversal-stage {
  0% { opacity: 0; }
  15%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes clash-reversal-confirm {
  0%, 22% { opacity: 0; }
  30%, 52% { opacity: 1; }
  78% { opacity: 0.4; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .clash-reversal-light {
    animation-duration: 180ms;
    animation-delay: var(--damage-calc-result-delay, 1200ms);
  }
}

.clash-labels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
}

.clash-labels span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clash-right-label {
  text-align: right;
}

.clash-damage {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  max-width: 122px;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid rgba(220, 107, 87, 0.58);
  border-radius: 999px;
  background: rgba(91, 35, 27, 0.74);
  color: #ffc4b8;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  animation: damage-badge-pop 520ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.clash-damage:lang(en) {
  max-width: none;
}

/* 結果値は先に計算済みでも、表示は実際の着弾まで伏せてSE・HP変化と同期する。 */
.battle-result .clash-damage {
  animation-delay: calc(var(--damage-motion-delay, 0ms) + var(--battle-impact-delay, 460ms));
}

.defeated-damage {
  border-color: rgba(255, 224, 136, 0.8);
  background: linear-gradient(135deg, rgba(128, 37, 31, 0.92), rgba(91, 35, 27, 0.82));
  color: #ffe2d9;
  box-shadow: 0 0 18px rgba(220, 107, 87, 0.34);
}

.clash-ko {
  color: #ffe19a;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.clash-damage-placeholder {
  min-width: 1px;
}

.clash-labels strong {
  display: inline-block;
  min-width: auto;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  text-align: right;
}

.clash-track {
  position: relative;
  height: 26px;
  border: 1px solid;
  border-color: #948469 #776e54 #57533f;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 34%, rgba(0, 0, 0, 0.2)),
    linear-gradient(90deg, rgba(245, 196, 86, 0.14), transparent 48%, transparent 52%, rgba(104, 208, 200, 0.14)),
    #0d100d;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.72),
    inset 0 -1px 0 rgba(231, 214, 174, 0.06),
    0 1px 0 rgba(9, 16, 13, 0.48);
}

.clash-center {
  position: absolute;
  inset: -6px auto -6px var(--clash-boundary, 50%);
  z-index: 2;
  width: 3px;
  border-radius: 999px;
  background: rgba(242, 239, 228, 0.88);
  box-shadow:
    0 0 0 1px rgba(17, 19, 16, 0.7),
    0 0 12px rgba(242, 239, 228, 0.32);
  transform: translateX(-1.5px);
  animation: clash-center-push 1300ms ease-out both;
}

.clash-stage-fill,
.clash-stage-center {
  display: none;
}

.damage-calc-staged .clash-fill-final,
.damage-calc-staged .clash-center-final {
  display: none;
}

.damage-calc-staged .clash-stage-fill {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  display: flex;
  width: var(--stage-width, 0%);
  min-width: 0;
  overflow: hidden;
  will-change: width, opacity;
}

.damage-calc-staged .clash-stage-left {
  left: 0;
  transform-origin: left center;
  animation-name: damage-calc-stage-fill-left;
}

.damage-calc-staged .clash-stage-right {
  right: 0;
  flex-direction: row-reverse;
  transform-origin: right center;
  animation-name: damage-calc-stage-fill-right;
}

.damage-calc-staged .clash-stage-fill::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: min(18px, 60%);
  background: linear-gradient(90deg, transparent, var(--stage-edge-color, rgba(255, 255, 255, 0.82)));
  box-shadow: 4px 0 12px var(--stage-edge-shadow, rgba(255, 255, 255, 0.34));
  opacity: 0;
  pointer-events: none;
  animation-name: damage-calc-stage-edge-flare;
  animation-duration: inherit;
  animation-delay: inherit;
  animation-timing-function: inherit;
  animation-fill-mode: both;
}

.damage-calc-staged .clash-stage-right::after {
  right: auto;
  left: 0;
  transform: scaleX(-1);
}

.damage-calc-staged .clash-stage-basic {
  --stage-edge-color: rgba(255, 123, 105, 0.96);
  --stage-edge-shadow: rgba(255, 86, 70, 0.48);
  z-index: 1;
  animation-duration: var(--damage-calc-basic-transition, 288ms);
  animation-delay: calc(var(--damage-calc-basic-delay, 60ms) - var(--damage-calc-stage-elapsed, 0ms));
  animation-timing-function: cubic-bezier(0.18, 0.9, 0.24, 1);
  animation-fill-mode: both;
}

.damage-calc-staged .clash-stage-weapon {
  --stage-edge-color: rgba(114, 184, 255, 0.96);
  --stage-edge-shadow: rgba(61, 147, 235, 0.5);
  z-index: 2;
  animation-duration: var(--damage-calc-weapon-transition, 317ms);
  animation-delay: calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-stage-elapsed, 0ms));
  animation-timing-function: cubic-bezier(0.18, 0.9, 0.24, 1);
  animation-fill-mode: both;
}

.damage-calc-staged .clash-stage-attribute {
  --stage-edge-color: rgba(126, 220, 209, 0.98);
  --stage-edge-shadow: rgba(60, 186, 173, 0.48);
  z-index: 3;
  animation-duration: var(--damage-calc-attribute-transition, 331ms);
  animation-delay: calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-stage-elapsed, 0ms));
  animation-timing-function: cubic-bezier(0.18, 0.9, 0.24, 1);
  animation-fill-mode: both;
}

.damage-calc-staged .clash-stage-center {
  position: absolute;
  inset: -6px auto -6px var(--stage-center-to, 50%);
  z-index: 5;
  display: block;
  width: 3px;
  border-radius: 999px;
  background: var(--stage-line-color, rgba(255, 250, 218, 0.96));
  box-shadow:
    0 0 0 1px rgba(17, 19, 16, 0.74),
    0 0 10px var(--stage-line-glow, rgba(255, 239, 169, 0.72)),
    0 0 22px var(--stage-line-glow-soft, rgba(255, 207, 88, 0.38));
  transform: translateX(-1.5px);
  will-change: left, opacity;
}

.damage-calc-staged .clash-stage-center-basic {
  --stage-line-color: #ff8a78;
  --stage-line-glow: rgba(255, 104, 84, 0.74);
  --stage-line-glow-soft: rgba(255, 77, 60, 0.38);
  --stage-electric-delay: calc(var(--damage-calc-basic-delay, 60ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-basic-transition, 288ms);
  animation: damage-calc-stage-center-hold calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-basic-delay, 60ms)) ease-out calc(var(--damage-calc-basic-delay, 60ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .clash-stage-center-weapon {
  --stage-line-color: #85c5ff;
  --stage-line-glow: rgba(92, 174, 248, 0.76);
  --stage-line-glow-soft: rgba(54, 142, 227, 0.4);
  --stage-electric-delay: calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-weapon-transition, 317ms);
  animation: damage-calc-stage-center-hold calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-weapon-delay, 460ms)) ease-out calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .clash-stage-center-attribute {
  --stage-line-color: #8de4da;
  --stage-line-glow: rgba(89, 205, 192, 0.78);
  --stage-line-glow-soft: rgba(56, 176, 164, 0.4);
  --stage-electric-delay: calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-attribute-transition, 331ms);
  animation: damage-calc-stage-center-finish var(--damage-calc-attribute-transition, 331ms) cubic-bezier(0.18, 0.9, 0.24, 1) calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-stage-elapsed, 0ms)) both;
}

.damage-calc-staged .clash-stage-center.has-stage-electric::before,
.damage-calc-staged .clash-stage-center.has-stage-electric::after {
  content: "";
  position: absolute;
  left: 50%;
  z-index: 2;
  display: block;
  pointer-events: none;
  mix-blend-mode: screen;
}

.damage-calc-staged .clash-stage-center.has-stage-electric::before {
  top: -2px;
  width: var(--stage-electric-width, 5px);
  height: calc(100% + 4px);
  background: linear-gradient(
    180deg,
    transparent 0,
    var(--stage-line-color) 10%,
    #fff 28%,
    var(--stage-line-color) 46%,
    #fff 64%,
    var(--stage-line-color) 84%,
    transparent 100%
  );
  clip-path: polygon(
    45% 0,
    78% 11%,
    35% 24%,
    72% 38%,
    28% 51%,
    70% 65%,
    38% 78%,
    62% 89%,
    48% 100%,
    28% 88%,
    52% 77%,
    20% 64%,
    56% 51%,
    24% 37%,
    58% 23%,
    30% 10%
  );
  filter:
    brightness(1.45)
    saturate(1.12)
    drop-shadow(0 0 calc(var(--stage-electric-glow, 7px) * 0.5) var(--stage-line-glow))
    drop-shadow(0 0 calc(var(--stage-electric-glow-wide, 12px) * 0.32) var(--stage-line-glow-soft));
  transform-origin: center;
  animation: damage-calc-electric-spine var(--stage-electric-duration, 320ms) steps(2, end) var(--stage-electric-delay, 0ms) both;
}

.damage-calc-staged .clash-stage-center.has-stage-electric::after {
  top: 50%;
  width: var(--stage-electric-reach, 18px);
  height: var(--stage-electric-height, 5px);
  background: linear-gradient(
    90deg,
    transparent 0,
    var(--stage-line-color) 12%,
    #fff 38%,
    #fff 62%,
    var(--stage-line-color) 88%,
    transparent 100%
  );
  clip-path: polygon(
    0 58%,
    10% 24%,
    21% 66%,
    31% 18%,
    42% 61%,
    50% 34%,
    58% 67%,
    69% 22%,
    80% 62%,
    90% 30%,
    100% 56%,
    90% 72%,
    80% 44%,
    69% 78%,
    58% 43%,
    50% 70%,
    42% 39%,
    31% 82%,
    21% 42%,
    10% 76%
  );
  filter:
    brightness(1.55)
    saturate(1.16)
    drop-shadow(0 0 calc(var(--stage-electric-glow, 7px) * 0.55) var(--stage-line-glow))
    drop-shadow(0 0 calc(var(--stage-electric-glow-wide, 12px) * 0.34) var(--stage-line-glow-soft));
  transform-origin: center;
  animation: damage-calc-electric-pressure var(--stage-electric-duration, 320ms) cubic-bezier(0.15, 0.82, 0.2, 1) var(--stage-electric-delay, 0ms) both;
}

.damage-calc-staged .clash-stage-electric-cluster {
  position: absolute;
  /* 段階ごとに画像サイズが変わっても、発光中心は同じ高さへ固定する。 */
  top: calc(50% + 14px);
  left: var(--stage-center-from, 50%);
  z-index: 7;
  display: block;
  width: var(--stage-cluster-width, 24px);
  height: var(--stage-cluster-height, 12px);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.44) 0, transparent 24%),
    url("../assets/effects/battle/damage_gauge_clash.webp") center / 118% auto no-repeat;
  filter:
    brightness(var(--stage-cluster-brightness, 1.12))
    sepia(0.18)
    saturate(1.24)
    drop-shadow(0 0 4px rgba(255, 248, 200, 0.7))
    drop-shadow(0 0 10px var(--stage-line-glow-soft));
  pointer-events: none;
  will-change: left, opacity, transform;
  animation:
    damage-calc-electric-cluster-pulse var(--stage-electric-duration, 320ms) cubic-bezier(0.16, 0.86, 0.2, 1) var(--stage-electric-delay, 0ms) both,
    damage-calc-electric-cluster-track var(--stage-electric-duration, 320ms) cubic-bezier(0.18, 0.9, 0.24, 1) var(--stage-electric-delay, 0ms) both;
}

.damage-calc-staged .clash-stage-electric-cluster::after {
  content: "";
  position: absolute;
  inset: -5% -8%;
  display: block;
  background: url("../assets/effects/battle/damage_gauge_clash.webp") center / 118% auto no-repeat;
  filter:
    blur(0.6px)
    brightness(var(--stage-cluster-echo-brightness, 1.34));
  transform-origin: center;
  animation: damage-calc-electric-cluster-echo var(--stage-electric-duration, 320ms) cubic-bezier(0.16, 0.82, 0.2, 1) calc(var(--stage-electric-delay, 0ms) + 40ms) both;
}

.damage-calc-staged .clash-stage-electric-cluster-basic {
  --stage-line-color: #ff8a78;
  --stage-line-glow: rgba(255, 104, 84, 0.78);
  --stage-line-glow-soft: rgba(255, 77, 60, 0.42);
  --stage-electric-delay: calc(var(--damage-calc-basic-delay, 60ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-basic-transition, 288ms);
}

.damage-calc-staged .clash-stage-electric-cluster-weapon {
  --stage-line-color: #85c5ff;
  --stage-line-glow: rgba(92, 174, 248, 0.8);
  --stage-line-glow-soft: rgba(54, 142, 227, 0.44);
  --stage-electric-delay: calc(var(--damage-calc-weapon-delay, 460ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-weapon-transition, 317ms);
}

.damage-calc-staged .clash-stage-electric-cluster-attribute {
  --stage-line-color: #8de4da;
  --stage-line-glow: rgba(89, 205, 192, 0.82);
  --stage-line-glow-soft: rgba(56, 176, 164, 0.44);
  --stage-electric-delay: calc(var(--damage-calc-attribute-delay, 900ms) - var(--damage-calc-stage-elapsed, 0ms));
  --stage-electric-duration: var(--damage-calc-attribute-transition, 331ms);
}

.has-damage-calc-shift .clash-center {
  animation: clash-center-damage-calc 2000ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.clash-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--gauge-width, 0%);
  min-width: 0;
  display: flex;
  overflow: hidden;
  will-change: transform;
}

.clash-left {
  left: 0;
  transform-origin: left center;
  animation: clash-fill-left 1300ms ease-out both;
}

.clash-right {
  right: 0;
  flex-direction: row-reverse;
  transform-origin: right center;
  animation: clash-fill-right 1300ms ease-out both;
}

.has-damage-calc-shift .clash-left {
  animation: clash-fill-left-damage-calc 2000ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.has-damage-calc-shift .clash-right {
  animation: clash-fill-right-damage-calc 2000ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.gauge-from-visible .clash-gauge:not(.has-damage-calc-shift) .clash-left,
.gauge-from-visible .clash-gauge:not(.has-damage-calc-shift) .clash-right,
.gauge-from-visible .clash-gauge:not(.has-damage-calc-shift) .clash-center {
  animation: none;
}

.gauge-from-visible .has-damage-calc-shift .clash-left {
  animation: clash-fill-left-shift-from-visible var(--damage-calc-correction-duration, 1200ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--damage-calc-correction-start-delay, 0ms);
}

.gauge-from-visible .has-damage-calc-shift .clash-right {
  animation: clash-fill-right-shift-from-visible var(--damage-calc-correction-duration, 1200ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--damage-calc-correction-start-delay, 0ms);
}

.gauge-from-visible .has-damage-calc-shift .clash-center {
  animation: clash-center-shift-from-visible var(--damage-calc-correction-duration, 1200ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--damage-calc-correction-start-delay, 0ms);
}

.meter-segment {
  position: relative;
  display: block;
  flex: var(--segment-weight, 1) 1 0;
  min-width: 0;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 236, 202, 0.09), transparent 32%, transparent 68%, rgba(12, 23, 17, 0.12)),
    var(--meter-main, #727a6d);
  box-shadow:
    inset 0 1px 0 rgba(249, 228, 188, 0.1),
    inset 0 -1px 0 rgba(12, 23, 17, 0.16);
}

.has-damage-calc-shift .segment-mod {
  animation: modifier-segment-pop 2000ms ease-out both;
}

.gauge-from-visible .has-damage-calc-shift .segment-mod {
  animation: modifier-segment-pop-from-visible var(--damage-calc-correction-duration, 1200ms) ease-out both;
  animation-delay: var(--damage-calc-correction-start-delay, 0ms);
}

@keyframes battle-calc-reveal {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes battle-process-hold {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 固定高の見出しを動かすと一瞬スクロール範囲が広がるため、文字は明暗だけで切り替える。 */
@keyframes battle-head-transition-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes battle-head-wait {
  0%, 100% { opacity: 0; }
  14%, 78% { opacity: 1; }
}

@keyframes battle-process-wait {
  0% {
    opacity: 0;
    transform: translateY(5px) scale(0.98);
  }

  14%,
  78% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-4px) scale(0.99);
  }
}

@keyframes clash-fill-left {
  from {
    transform: scaleX(0.001);
  }
}

@keyframes clash-fill-right {
  from {
    transform: scaleX(0.001);
  }
}

@keyframes clash-fill-left-damage-calc {
  0% {
    width: 0%;
  }

  30%,
  40% {
    width: var(--initial-width, var(--gauge-width, 0%));
  }

  100% {
    width: var(--gauge-width, 0%);
  }
}

@keyframes clash-fill-right-damage-calc {
  0% {
    width: 0%;
  }

  30%,
  40% {
    width: var(--initial-width, var(--gauge-width, 0%));
  }

  100% {
    width: var(--gauge-width, 0%);
  }
}

@keyframes clash-center-push {
  from {
    left: 50%;
  }
}

@keyframes clash-center-damage-calc {
  0% {
    left: 50%;
  }

  30%,
  40% {
    left: var(--clash-boundary-start, 50%);
  }

  100% {
    left: var(--clash-boundary, 50%);
  }
}

@keyframes clash-fill-left-shift-from-visible {
  0%,
  22% {
    width: var(--initial-width, var(--gauge-width, 0%));
  }

  100% {
    width: var(--gauge-width, 0%);
  }
}

@keyframes clash-fill-right-shift-from-visible {
  0%,
  22% {
    width: var(--initial-width, var(--gauge-width, 0%));
  }

  100% {
    width: var(--gauge-width, 0%);
  }
}

@keyframes clash-center-shift-from-visible {
  0%,
  22% {
    left: var(--clash-boundary-start, 50%);
  }

  100% {
    left: var(--clash-boundary, 50%);
  }
}

@keyframes modifier-segment-pop {
  0%,
  34% {
    flex-grow: 0.001;
    opacity: 0;
    filter: brightness(1.8);
  }

  48% {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
    filter: brightness(1.55);
  }

  68% {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
    filter: brightness(1.15);
  }

  100% {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes modifier-segment-pop-from-visible {
  0%,
  22% {
    flex-grow: 0.001;
    opacity: 0;
    filter: brightness(1.8);
  }

  42% {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
    filter: brightness(1.55);
  }

  100% {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes damage-calc-stage-fill-left {
  0% {
    width: var(--stage-from-width, 0%);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    width: var(--stage-width, 0%);
    opacity: 1;
  }
}

@keyframes damage-calc-stage-fill-right {
  0% {
    width: var(--stage-from-width, 0%);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    width: var(--stage-width, 0%);
    opacity: 1;
  }
}

@keyframes damage-calc-stage-edge-flare {
  0%,
  12% {
    opacity: 0;
  }

  44% {
    opacity: 0.42;
  }

  76% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes damage-calc-electric-spine {
  0%,
  8% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0.24);
  }

  22% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translateX(calc(-50% - var(--stage-electric-jitter, 1px))) scaleY(0.86);
  }

  38% {
    opacity: 0.3;
    transform: translateX(calc(-50% + var(--stage-electric-jitter, 1px))) scaleY(1);
  }

  52% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translateX(calc(-50% - var(--stage-electric-jitter, 1px))) scaleY(0.92);
  }

  68% {
    opacity: 0.34;
    transform: translateX(calc(-50% + var(--stage-electric-jitter, 1px))) scaleY(1);
  }

  82% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translateX(-50%) scaleY(0.96);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0.68);
  }
}

@keyframes damage-calc-electric-pressure {
  0%,
  8% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.08);
  }

  20% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translate(
      calc(-50% - var(--stage-electric-jitter, 1px)),
      -50%
    ) scaleX(0.7);
  }

  36% {
    opacity: 0.28;
    transform: translate(
      calc(-50% + var(--stage-electric-jitter, 1px)),
      -50%
    ) scaleX(0.94);
  }

  50% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translate(
      calc(-50% - var(--stage-electric-jitter, 1px)),
      -50%
    ) scaleX(1);
  }

  66% {
    opacity: 0.32;
    transform: translate(
      calc(-50% + var(--stage-electric-jitter, 1px)),
      -50%
    ) scaleX(0.82);
  }

  80% {
    opacity: var(--stage-electric-opacity, 0.48);
    transform: translate(-50%, -50%) scaleX(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.72);
  }
}

@keyframes damage-calc-electric-cluster-pulse {
  0%,
  8% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.32);
  }

  24% {
    opacity: var(--stage-cluster-opacity, 0.62);
    transform: translate(-50%, -50%) scale(0.88);
  }

  46% {
    opacity: 0.42;
    transform: translate(-50%, -50%) scale(1);
  }

  66% {
    opacity: var(--stage-cluster-opacity, 0.62);
    transform: translate(-50%, -50%) scale(0.94);
  }

  82% {
    opacity: 0.46;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.74);
  }
}

@keyframes damage-calc-electric-cluster-track {
  from {
    left: var(--stage-center-from, 50%);
  }

  to {
    left: var(--stage-center-to, 50%);
  }
}

@keyframes damage-calc-electric-cluster-echo {
  0%,
  16% {
    opacity: 0;
    transform: scaleX(0.18) scaleY(0.56);
  }

  34% {
    opacity: 0.52;
    transform: scaleX(0.84) scaleY(0.92);
  }

  58% {
    opacity: 0.28;
    transform: scaleX(1.08) scaleY(1);
  }

  76% {
    opacity: 0.42;
    transform: scaleX(1.16) scaleY(0.94);
  }

  100% {
    opacity: 0;
    transform: scaleX(1.28) scaleY(0.82);
  }
}

@keyframes damage-calc-stage-center-hold {
  0% {
    left: var(--stage-center-from, 50%);
    opacity: 0;
  }

  12% {
    opacity: 1;
  }

  72%,
  82% {
    left: var(--stage-center-to, 50%);
    opacity: 1;
  }

  100% {
    left: var(--stage-center-to, 50%);
    opacity: 0;
  }
}

@keyframes damage-calc-stage-center-finish {
  0% {
    left: var(--stage-center-from, 50%);
    opacity: 0;
  }

  16% {
    opacity: 1;
  }

  72% {
    filter: brightness(1.8);
  }

  100% {
    left: var(--stage-center-to, 50%);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes damage-calc-formula-stage {
  0% {
    opacity: 0.58;
    box-shadow: none;
    transform: translateY(2px) scale(0.98);
  }

  34% {
    opacity: 1;
    border-color: var(--calc-border, rgba(255, 248, 194, 0.82));
    box-shadow:
      0 0 0 1px var(--calc-glow-soft, rgba(255, 239, 164, 0.24)),
      0 0 14px var(--calc-glow, rgba(255, 220, 116, 0.48));
    transform: translateY(0) scale(1.06);
  }

  100% {
    opacity: 1;
    box-shadow: none;
    transform: translateY(0) scale(1);
  }
}

@keyframes damage-calc-correction-term {
  0% {
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: none;
  }

  46% {
    border-color: rgba(224, 203, 255, 0.9);
    box-shadow:
      0 0 0 1px rgba(190, 158, 255, 0.28),
      0 0 16px rgba(141, 121, 220, 0.62);
  }

  100% {
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: none;
  }
}

@keyframes damage-calc-number-before-up {
  0%,
  24% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-92%);
  }
}

@keyframes damage-calc-number-after-up {
  0%,
  24% {
    opacity: 0;
    transform: translateY(92%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes damage-calc-number-before-down {
  0%,
  24% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(92%);
  }
}

@keyframes damage-calc-number-after-down {
  0%,
  24% {
    opacity: 0;
    transform: translateY(-92%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes damage-calc-correction-head-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* 動きを減らす設定でも、補正→結果→着弾の表示順だけは一瞬の切替で維持する。 */
@keyframes damage-calc-reduced-before {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes damage-calc-reduced-after {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes damage-calc-reduced-fill {
  from {
    width: var(--initial-width, var(--gauge-width, 0%));
  }

  to {
    width: var(--gauge-width, 0%);
  }
}

@keyframes damage-calc-reduced-center {
  from {
    left: var(--clash-boundary-start, 50%);
  }

  to {
    left: var(--clash-boundary, 50%);
  }
}

@keyframes damage-calc-reduced-modifier {
  from {
    flex-grow: 0.001;
    opacity: 0;
  }

  to {
    flex-grow: var(--segment-weight, 1);
    opacity: 1;
  }
}

@keyframes damage-badge-pop {
  0% {
    opacity: 0;
    transform: translateY(4px) scale(0.82);
  }

  62% {
    transform: translateY(0) scale(1.1);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes battle-selection-breathe {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(255, 225, 154, 0.52),
      0 0 16px rgba(255, 225, 154, 0.28),
      0 0 28px rgba(116, 232, 158, 0.1),
      0 10px 22px rgba(0, 0, 0, 0.34);
  }

  50% {
    box-shadow:
      0 0 0 2px rgba(255, 225, 154, 0.78),
      0 0 24px rgba(255, 225, 154, 0.46),
      0 0 38px rgba(116, 232, 158, 0.18),
      0 10px 22px rgba(0, 0, 0, 0.36);
  }
}

@keyframes battle-predesignation-breathe {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(116, 232, 200, 0.48),
      0 0 14px rgba(116, 232, 200, 0.28),
      0 0 26px rgba(255, 225, 154, 0.12);
  }

  50% {
    box-shadow:
      0 0 0 3px rgba(116, 232, 200, 0.76),
      0 0 24px rgba(116, 232, 200, 0.48),
      0 0 38px rgba(255, 225, 154, 0.22);
  }
}

@keyframes battle-process-effect-break {
  0% {
    transform: scale(0.98);
    filter: brightness(1.6);
  }

  24% {
    transform: translateX(-3px) scale(1.01);
  }

  34% {
    transform: translateX(3px) scale(1.01);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes battle-process-effect-break-label {
  0% {
    transform: translateY(4px) scale(0.72);
    opacity: 0;
  }

  24%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes battle-route-attacker-call {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  50% {
    transform: translateX(7px) scale(1.035);
    filter: brightness(1.18) saturate(1.08);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.04);
  }
}

@keyframes battle-route-attacker-call-reversed {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  50% {
    transform: translateX(-7px) scale(1.035);
    filter: brightness(1.18) saturate(1.08);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.04);
  }
}

@keyframes battle-route-target-call {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  48% {
    transform: translateX(-4px) scale(1.015);
    filter: brightness(1.16) saturate(1.08);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.03);
  }
}

@keyframes battle-route-target-call-reversed {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  48% {
    transform: translateX(4px) scale(1.015);
    filter: brightness(1.16) saturate(1.08);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.03);
  }
}

@keyframes battle-route-blocker-call {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  48% {
    transform: translateX(-7px) scale(1.04);
    filter: brightness(1.2) saturate(1.12);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.05);
  }
}

@keyframes battle-route-blocker-call-reversed {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }

  48% {
    transform: translateX(7px) scale(1.04);
    filter: brightness(1.2) saturate(1.12);
  }

  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1.05);
  }
}

@keyframes battle-route-arrow-call {
  0% {
    transform: scale(0.92);
    filter: brightness(1);
  }

  38% {
    transform: scale(1.22);
    filter: brightness(1.5);
  }

  100% {
    transform: scale(1);
    filter: brightness(1.08);
  }
}

@keyframes battle-route-call-line {
  0% {
    opacity: 0.28;
    transform: translateY(-50%) scaleX(0.12);
  }

  42% {
    opacity: 1;
    transform: translateY(-50%) scaleX(1);
  }

  100% {
    opacity: 0.72;
    transform: translateY(-50%) scaleX(1);
  }
}

@keyframes battle-winner-glint {
  0% {
    opacity: 0;
  }

  24% {
    opacity: 0.78;
  }

  100% {
    opacity: 0;
  }
}

@keyframes battle-weapon-ready-left {
  0% {
    opacity: 0;
    transform: translate(-28px, 12px) rotate(-8deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(-8px, 2px) rotate(-2deg) scale(1);
  }
}

@keyframes battle-weapon-ready-right {
  0% {
    opacity: 0;
    transform: translate(30px, 12px) rotate(8deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(8px, 2px) rotate(2deg) scale(1);
  }
}

@keyframes battle-weapon-ready-pierce-left {
  0% {
    opacity: 0;
    transform: translate(-28px, 12px) rotate(26deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(-8px, 4px) rotate(42deg) scale(1);
  }
}

@keyframes battle-weapon-ready-pierce-right {
  0% {
    opacity: 0;
    transform: translate(32px, 12px) rotate(-26deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(12px, 4px) rotate(-42deg) scale(1);
  }
}

@keyframes battle-weapon-ready-blow-left {
  0% {
    opacity: 0;
    transform: translate(-28px, 4px) rotate(-24deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(-8px, -16px) rotate(-42deg) scale(1.02);
  }
}

@keyframes battle-weapon-ready-blow-right {
  0% {
    opacity: 0;
    transform: translate(32px, 4px) rotate(24deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(12px, -16px) rotate(42deg) scale(1.02);
  }
}

@keyframes battle-weapon-ready-arrow-left {
  0% {
    opacity: 0;
    transform: translate(-26px, 10px) rotate(-24deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(-10px, 0) rotate(-42deg) scale(1);
  }
}

@keyframes battle-weapon-ready-arrow-right {
  0% {
    opacity: 0;
    transform: translate(30px, 10px) rotate(24deg) scale(0.88);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(14px, 0) rotate(42deg) scale(1);
  }
}

@keyframes battle-weapon-ready-guard-left {
  0% {
    opacity: 0;
    transform: translate(-18px, 8px) rotate(0deg) scale(0.9);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-ready-guard-right {
  0% {
    opacity: 0;
    transform: translate(22px, 8px) rotate(0deg) scale(0.9);
  }

  42% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-unit-attack {
  0% {
    opacity: 1;
    transform: translateX(-8px) scale(0.98);
  }

  24% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  48% {
    transform: translateX(12px) scale(1.04);
  }

  72%,
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes battle-unit-defense {
  0% {
    opacity: 1;
    transform: translateX(8px) scale(0.98);
  }

  24% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  48% {
    transform: translateX(-10px) scale(1.03);
  }

  72%,
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes battle-unit-hit {
  0% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(0.98);
  }

  24% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(0.98);
  }

  46% {
    transform: translateX(var(--unit-start-x, 0px)) scale(1.02);
  }

  58% {
    transform: translateX(-7px) rotate(-2deg);
  }

  70% {
    transform: translateX(5px) rotate(2deg);
  }

  86%,
  100% {
    opacity: 1;
    transform: translateX(0) rotate(0) scale(1);
  }
}

@keyframes battle-attr-damage-flash {
  0% {
    opacity: 0;
    transform: scale(0.97);
  }

  16% {
    opacity: 0.9;
    transform: scale(1.025);
  }

  38% {
    opacity: 0.44;
    transform: scale(1.01);
  }

  58% {
    opacity: 0.68;
    transform: scale(1.035);
  }

  100% {
    opacity: 0;
    transform: scale(1.06);
  }
}

@keyframes battle-effect-hp-change {
  0% {
    opacity: 0;
    transform: translate(-50%, -34%) scale(0.72);
  }

  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18);
  }

  68% {
    opacity: 1;
    transform: translate(-50%, -64%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -92%) scale(0.94);
  }
}

@keyframes battle-unit-defeat {
  0% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(0.98);
  }

  24% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(0.98);
  }

  44% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(1.02);
  }

  56% {
    opacity: 1;
    transform: translateX(-8px) rotate(-3deg) scale(0.98);
  }

  68% {
    opacity: 0.82;
    transform: translateX(5px) translateY(3px) rotate(2deg) scale(0.94);
  }

  84% {
    opacity: 0.28;
    transform: translateY(14px) rotate(-2deg) scale(0.82);
    filter: blur(0.4px);
  }

  100% {
    opacity: 0;
    transform: translateY(18px) rotate(-3deg) scale(0.74);
    filter: blur(1px);
  }
}

@keyframes battle-unit-finish-defeat {
  0% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(0.98);
  }

  26% {
    opacity: 1;
    transform: translateX(var(--unit-start-x, 0px)) scale(1.03);
  }

  44% {
    opacity: 1;
    transform: translateX(-11px) translateY(-2px) rotate(-4deg) scale(1.02);
    filter: brightness(1.12);
  }

  62% {
    opacity: 0.72;
    transform: translateX(8px) translateY(5px) rotate(4deg) scale(0.9);
    filter: brightness(0.82) blur(0.2px);
  }

  82% {
    opacity: 0.2;
    transform: translateY(22px) rotate(-4deg) scale(0.74);
    filter: brightness(0.62) blur(0.7px);
  }

  100% {
    opacity: 0;
    transform: translateY(30px) rotate(-6deg) scale(0.62);
    filter: brightness(0.48) blur(1.3px);
  }
}

@keyframes battle-impact-sync-marker {
  from {
    opacity: 0;
  }

  to {
    opacity: 0.001;
  }
}

@keyframes battle-weapon-attack {
  0% {
    opacity: 1;
    transform: translate(-8px, 2px) rotate(-2deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(-8px, 2px) rotate(-2deg) scale(1);
  }

  46% {
    transform: translate(50px, -16px) rotate(32deg) scale(1.16);
    /* 戻りを途中で区切らず、一度の減速で構えへつなぐ。 */
    animation-timing-function: cubic-bezier(0.2, 0.9, 0.2, 1);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-defense {
  0% {
    opacity: 1;
    transform: translate(8px, 2px) rotate(2deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(8px, 2px) rotate(2deg) scale(1);
  }

  46% {
    transform: translate(-64px, -16px) rotate(-32deg) scale(1.15);
    animation-timing-function: cubic-bezier(0.2, 0.9, 0.2, 1);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-pierce-left {
  0% {
    opacity: 1;
    transform: translate(-8px, 4px) rotate(42deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(-8px, 4px) rotate(42deg) scale(1);
  }

  46% {
    transform: translate(58px, 4px) rotate(44deg) scale(1.14);
  }

  62% {
    transform: translate(4px, 2px) rotate(42deg) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(38deg) scale(1);
  }
}

@keyframes battle-weapon-pierce-right {
  0% {
    opacity: 1;
    transform: translate(12px, 4px) rotate(-42deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(12px, 4px) rotate(-42deg) scale(1);
  }

  46% {
    transform: translate(-58px, 4px) rotate(-44deg) scale(1.14);
  }

  62% {
    transform: translate(-4px, 2px) rotate(-42deg) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(-38deg) scale(1);
  }
}

@keyframes battle-weapon-blow-left {
  0% {
    opacity: 1;
    transform: translate(-8px, -16px) rotate(-42deg) scale(1.02);
  }

  24% {
    opacity: 1;
    transform: translate(-8px, -16px) rotate(-42deg) scale(1.02);
  }

  48% {
    transform: translate(26px, 24px) rotate(72deg) scale(1.12);
  }

  66% {
    transform: translate(2px, 4px) rotate(14deg) scale(1.03);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-blow-right {
  0% {
    opacity: 1;
    transform: translate(12px, -16px) rotate(42deg) scale(1.02);
  }

  24% {
    opacity: 1;
    transform: translate(12px, -16px) rotate(42deg) scale(1.02);
  }

  48% {
    transform: translate(-28px, 24px) rotate(-72deg) scale(1.12);
  }

  66% {
    transform: translate(-2px, 4px) rotate(-14deg) scale(1.03);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-arrow-left {
  0% {
    opacity: 1;
    transform: translate(-10px, 0) rotate(-42deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(-10px, 0) rotate(-42deg) scale(1);
  }

  48% {
    transform: translate(22px, 0) rotate(-42deg) scale(1.03);
  }

  70% {
    transform: translate(2px, 0) rotate(-42deg) scale(1.01);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(-42deg) scale(1);
  }
}

@keyframes battle-weapon-arrow-right {
  0% {
    opacity: 1;
    transform: translate(14px, 0) rotate(42deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(14px, 0) rotate(42deg) scale(1);
  }

  48% {
    transform: translate(-22px, 0) rotate(42deg) scale(1.03);
  }

  70% {
    transform: translate(-2px, 0) rotate(42deg) scale(1.01);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(42deg) scale(1);
  }
}

@keyframes battle-weapon-guard-left {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  42% {
    transform: translate(-3px, 1px) rotate(-2deg) scale(1.02);
  }

  48% {
    transform: translate(2px, -1px) rotate(2deg) scale(1.01);
  }

  56% {
    transform: translate(-1px, 0) rotate(-1deg) scale(1.005);
  }

  66%,
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-guard-right {
  0% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }

  24% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }

  42% {
    transform: translate(7px, 1px) rotate(2deg) scale(1.02);
  }

  48% {
    transform: translate(2px, -1px) rotate(-2deg) scale(1.01);
  }

  56% {
    transform: translate(5px, 0) rotate(1deg) scale(1.005);
  }

  66%,
  100% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-weapon-guard-art-glow {
  0% {
    filter:
      brightness(1)
      saturate(1);
  }

  18% {
    filter:
      brightness(1.5)
      saturate(1.28)
      drop-shadow(0 0 12px rgba(227, 252, 255, 0.9))
      drop-shadow(0 0 26px rgba(118, 184, 255, 0.56));
  }

  46%,
  62% {
    filter:
      brightness(1.24)
      saturate(1.12)
      drop-shadow(0 0 9px rgba(215, 250, 255, 0.64))
      drop-shadow(0 0 18px rgba(118, 184, 255, 0.36));
  }

  100% {
    filter:
      brightness(1)
      saturate(1);
  }
}

/* 直接魔法の魔法陣は位置を動かさず、展開中ずっと同じ場所で回す。 */
@keyframes battle-magic-circle-spin {
  0% {
    transform: scaleX(var(--battle-magic-circle-flip)) rotate(0deg) scale(var(--battle-magic-circle-scale));
  }

  100% {
    transform: scaleX(var(--battle-magic-circle-flip)) rotate(var(--battle-magic-circle-spin-end)) scale(var(--battle-magic-circle-scale));
  }
}

@keyframes battle-magic-circle-fade-out {
  0% {
    opacity: var(--battle-magic-circle-opacity);
  }

  100% {
    opacity: 0;
  }
}

@keyframes battle-magic-circle-break-fade {
  0%,
  50% {
    opacity: var(--battle-magic-circle-opacity);
  }

  60% {
    opacity: 0.88;
  }

  72% {
    opacity: 0.3;
  }

  100% {
    opacity: 0;
  }
}

@keyframes battle-magic-book-cast-left {
  0%,
  24% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  38% {
    transform: translate(-2px, -5px) rotate(-4deg) scale(1.04);
  }

  52% {
    transform: translate(4px, -2px) rotate(3deg) scale(1.02);
  }

  70%,
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-magic-book-cast-right {
  0%,
  24% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }

  38% {
    transform: translate(6px, -5px) rotate(-4deg) scale(1.04);
  }

  52% {
    transform: translate(0, -2px) rotate(3deg) scale(1.02);
  }

  70%,
  100% {
    opacity: 1;
    transform: translate(4px, 0) rotate(0deg) scale(1);
  }
}

@keyframes battle-magic-circle-cast {
  0%,
  24% {
    opacity: 0;
    transform: rotate(8deg) scale(0.68);
  }

  46% {
    opacity: 0.86;
    transform: rotate(42deg) scale(1.04);
  }

  62% {
    opacity: 0.62;
    transform: rotate(66deg) scale(1.08);
  }

  78% {
    opacity: 0.28;
    transform: rotate(86deg) scale(1.02);
  }

  100% {
    opacity: 0;
    transform: rotate(112deg) scale(1.12);
  }
}

@keyframes battle-magic-book-ray {
  0%,
  34% {
    opacity: 0;
    transform: scaleX(0.1);
  }

  46% {
    opacity: 0.94;
    transform: scaleX(1);
  }

  62% {
    opacity: 0.44;
    transform: scaleX(0.68);
  }

  100% {
    opacity: 0;
    transform: scaleX(1.18);
  }
}

@keyframes battle-magic-spell-cast {
  0% {
    opacity: 0;
    transform: translate(calc(var(--battle-magic-spell-x) + var(--battle-magic-spell-entry-x)), calc(var(--battle-magic-spell-cast-y) + 10px)) scale(0.34);
  }

  24% {
    opacity: 0;
    transform: translate(calc(var(--battle-magic-spell-x) + var(--battle-magic-spell-entry-x)), calc(var(--battle-magic-spell-cast-y) + 10px)) scale(0.34);
  }

  46% {
    opacity: 1;
    transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(1.08);
  }

  62% {
    opacity: 0.96;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 2px)) scale(1.01);
  }

  82% {
    opacity: 0.74;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 4px)) scale(1.05);
  }

  100% {
    opacity: 0;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 4px)) scale(1.05);
  }
}

@keyframes battle-magic-spell-break {
  0% {
    opacity: 0;
    transform: translate(calc(var(--battle-magic-spell-x) + var(--battle-magic-spell-entry-x)), calc(var(--battle-magic-spell-cast-y) + 10px)) scale(0.34);
  }

  24% {
    opacity: 0;
    transform: translate(calc(var(--battle-magic-spell-x) + var(--battle-magic-spell-entry-x)), calc(var(--battle-magic-spell-cast-y) + 10px)) scale(0.34);
  }

  46% {
    opacity: 1;
    transform: translate(var(--battle-magic-spell-x), var(--battle-magic-spell-cast-y)) scale(1.06);
  }

  58% {
    opacity: 0.94;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 2px)) scale(0.98);
  }

  72% {
    opacity: 0.38;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 3px)) scale(0.78);
  }

  100% {
    opacity: 0;
    transform: translate(var(--battle-magic-spell-x), calc(var(--battle-magic-spell-cast-y) - 3px)) scale(0.5);
  }
}

@keyframes battle-magic-aura {
  0% {
    opacity: 0;
    transform: scale(0.58);
  }

  24% {
    opacity: 0;
    transform: scale(0.58);
  }

  46% {
    opacity: 0.78;
    transform: scale(0.92);
  }

  62% {
    opacity: 0.5;
    transform: scale(1.02);
  }

  100% {
    opacity: 0;
    transform: scale(1.12);
  }
}

@keyframes battle-magic-shock-ring {
  0%,
  24% {
    opacity: 0;
    transform: scale(0.28);
  }

  46% {
    opacity: 0.96;
    transform: scale(0.78);
  }

  62% {
    opacity: 0.46;
    transform: scale(1.04);
  }

  100% {
    opacity: 0;
    transform: scale(1.34);
  }
}

@keyframes battle-weapon-break-fade {
  0% {
    opacity: 1;
  }

  20%,
  52% {
    opacity: 1;
  }

  68% {
    opacity: 0.42;
  }

  100% {
    opacity: 0;
  }
}

@keyframes battle-weapon-effect-return {
  0% {
    opacity: 1;
    filter: brightness(1.08);
  }

  42% {
    opacity: 0.72;
    filter: brightness(1.18);
  }

  100% {
    opacity: 0;
    filter: brightness(0.82) blur(1px);
  }
}

@keyframes battle-weapon-effect-return-magic {
  0% {
    opacity: 1;
    filter: brightness(1.14);
  }

  45% {
    opacity: 0.66;
    filter: brightness(1.24);
  }

  100% {
    opacity: 0;
    filter: brightness(0.82) blur(1px);
  }
}

@keyframes weapon-fragment-a {
  0%,
  50% {
    opacity: 0;
    transform: translate(0, 0) rotate(0) scale(0.7);
  }

  62% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-30px, -24px) rotate(-84deg) scale(0.9);
  }
}

@keyframes weapon-fragment-b {
  0%,
  50% {
    opacity: 0;
    transform: translate(0, 0) rotate(0) scale(0.7);
  }

  62% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(30px, -20px) rotate(96deg) scale(0.82);
  }
}

@keyframes weapon-fragment-c {
  0%,
  50% {
    opacity: 0;
    transform: translate(0, 0) rotate(0) scale(0.7);
  }

  62% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(5px, 30px) rotate(144deg) scale(0.86);
  }
}

@keyframes weapon-break-label {
  0%,
  44% {
    opacity: 0;
    transform: translateY(4px) scale(0.82);
  }

  58% {
    opacity: 1;
    transform: translateY(0) scale(1.14);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes weapon-durability-label {
  0%,
  42% {
    opacity: 0;
    transform: translateY(5px) scale(0.82);
  }

  56% {
    opacity: 1;
    transform: translateY(0) scale(1.16);
  }

  72% {
    opacity: 1;
    transform: translateY(0) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes direct-avatar-hit {
  0% {
    opacity: 1;
    transform: translateX(0) scale(0.98);
  }

  34% {
    opacity: 1;
    transform: translateX(0) scale(1.02);
  }

  48% {
    transform: translateX(-8px) rotate(-3deg) scale(1.08);
  }

  62% {
    transform: translateX(6px) rotate(3deg) scale(1.02);
  }

  78% {
    transform: translateX(-3px) rotate(-1deg) scale(1);
  }

  100% {
    opacity: 1;
    transform: translateX(0) rotate(0) scale(1);
  }
}

@keyframes battle-no-weapon-attack {
  0% {
    opacity: 1;
    transform: translateX(-8px) scale(0.96);
  }

  44% {
    opacity: 1;
    transform: translateX(12px) scale(1.08);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes battle-no-weapon-defense {
  0% {
    opacity: 1;
    transform: translateX(8px) scale(0.96);
  }

  44% {
    opacity: 1;
    transform: translateX(-10px) scale(1.06);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes battle-impact-flash {
  0% {
    opacity: 0;
    transform: scaleY(0.35) rotate(var(--impact-rotate, 36deg));
  }

  22% {
    opacity: 1;
    transform: scaleY(1) rotate(var(--impact-rotate, 36deg));
  }

  100% {
    opacity: 0.42;
    transform: scaleY(0.82) rotate(var(--impact-rotate, 36deg));
  }
}

@keyframes battle-impact-label {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }

  24% {
    opacity: 1;
    transform: scale(1.16);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes finish-impact-flash {
  0% {
    opacity: 0;
    transform: scaleY(0.28) rotate(var(--impact-rotate, 36deg));
  }

  20% {
    opacity: 1;
    transform: scaleY(1.2) rotate(var(--impact-rotate, 36deg));
  }

  56% {
    opacity: 0.76;
    transform: scaleY(0.92) rotate(var(--impact-rotate, 36deg));
  }

  100% {
    opacity: 0;
    transform: scaleY(1.34) rotate(var(--impact-rotate, 36deg));
  }
}

@keyframes finish-impact-label {
  0% {
    opacity: 0;
    transform: translateX(var(--finish-impact-offset-x, 0)) scale(0.62) rotate(-4deg);
  }

  20% {
    opacity: 1;
    transform: translateX(var(--finish-impact-offset-x, 0)) scale(1.34) rotate(2deg);
  }

  42% {
    transform: translateX(var(--finish-impact-offset-x, 0)) scale(0.96) rotate(-1deg);
  }

  100% {
    opacity: 1;
    transform: translateX(var(--finish-impact-offset-x, 0)) scale(1) rotate(0);
  }
}

@keyframes finish-title-pop {
  0%,
  30% {
    opacity: 0;
    transform: translateY(-8px) scale(0.92);
  }

  46% {
    opacity: 1;
    transform: translateY(0) scale(1.13);
  }

  64%,
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes finish-stage-pulse {
  0%,
  30% {
    filter: brightness(1);
  }

  45% {
    filter: brightness(1.24);
  }

  100% {
    filter: brightness(1.04);
  }
}

@keyframes finish-stage-ring {
  0%,
  28% {
    opacity: 0;
    transform: scale(0.74);
    filter: blur(0);
  }

  44% {
    opacity: 0.92;
    transform: scale(1);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: scale(1.28);
    filter: blur(2px);
  }
}

@keyframes avatar-attack {
  0% {
    transform: translateX(0) scale(1);
  }

  35% {
    transform: translateX(10px) scale(1.08);
  }

  100% {
    transform: translateX(0) scale(1);
  }
}

@keyframes avatar-damage {
  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-7px) rotate(-3deg);
  }

  42% {
    transform: translateX(6px) rotate(3deg);
  }

  64% {
    transform: translateX(-3px);
  }
}

@keyframes avatar-guts {
  0% {
    transform: translateY(0) scale(1);
  }

  42% {
    transform: translateY(-8px) scale(1.08);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes battle-attribute-link-pulse {
  0%, 100% {
    filter: brightness(1);
    transform: scale(1);
  }

  36%, 62% {
    filter: brightness(1.34) saturate(1.18);
    transform: scale(1.16);
  }
}

@media (prefers-reduced-motion: reduce) {
  .damage-calc-staged .clash-stage-center.has-stage-electric::before,
  .damage-calc-staged .clash-stage-center.has-stage-electric::after,
  .damage-calc-staged .clash-stage-electric-cluster {
    display: none;
    animation: none;
  }

  .damage-calc-staged .clash-stage-fill::after {
    display: none;
    animation: none;
  }

  .damage-calc-staged .clash-stage-fill,
  .damage-calc-staged .clash-stage-center {
    display: none;
    animation: none;
  }

  .damage-calc-staged .clash-stage-fill.is-final-stage {
    display: flex;
    width: var(--stage-width, 0%);
    opacity: 1;
    filter: none;
    animation: none;
  }

  .damage-calc-staged .clash-stage-center.is-final-stage {
    display: block;
    left: var(--stage-center-to, 50%);
    opacity: 1;
    filter: none;
    animation: none;
  }

  .damage-calc-staged .formula-term,
  .formula-term.correction-up,
  .formula-term.correction-down {
    opacity: 1;
    box-shadow: none;
    transform: none;
    animation: none;
  }

  .gauge-from-visible .has-damage-calc-shift .clash-left,
  .gauge-from-visible .has-damage-calc-shift .clash-right {
    animation: damage-calc-reduced-fill 1ms step-end var(--damage-calc-result-delay, 1200ms) both;
  }

  .gauge-from-visible .has-damage-calc-shift .clash-center {
    animation: damage-calc-reduced-center 1ms step-end var(--damage-calc-result-delay, 1200ms) both;
  }

  .gauge-from-visible .has-damage-calc-shift .segment-mod {
    filter: none;
    animation: damage-calc-reduced-modifier 1ms step-end var(--damage-calc-result-delay, 1200ms) both;
  }

  .damage-calc-number-before {
    transform: none;
    animation: damage-calc-reduced-before 1ms step-end var(--damage-calc-result-delay, 1200ms) both !important;
  }

  .damage-calc-number-after {
    transform: none;
    animation: damage-calc-reduced-after 1ms step-end var(--damage-calc-result-delay, 1200ms) both !important;
  }

  .battle-result.has-delayed-damage-calc-result .battle-correction-head {
    animation: damage-calc-reduced-before 1ms step-end var(--damage-calc-result-delay, 1200ms) both;
  }

  .battle-result.has-delayed-damage-calc-result .battle-result-head,
  .battle-result.has-head-transition.has-delayed-damage-calc-result .battle-result-head {
    transform: none;
    animation: damage-calc-reduced-after 1ms step-end var(--damage-calc-result-delay, 1200ms) both;
  }

  .battle-result .clash-damage {
    transform: none;
    animation: damage-calc-reduced-after 1ms step-end calc(var(--damage-motion-delay, 0ms) + var(--battle-impact-delay, 460ms)) both;
  }
}

/* 縦画面は計算欄を先に確保し、残りに戦士と武器を同じ比率で収める。 */
@media (max-width: 620px) and (orientation: portrait),
  (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  /* 説明は内容の高さまで描き、予約した計算欄を超える分は外側の戦闘パネルで読む。 */
  .app.mobile-layout .battle-result.battle-process-only.has-battle-process .battle-process-detail {
    inset: 0 0 auto;
    min-height: 100%;
    overflow: visible;
  }

  .app.mobile-layout .control-panel.has-pending-battle .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) {
    height: 100%;
    min-height: 0;
    /* 最小でもカード高96px＋武器名18px＋内側余白18pxを残す。 */
    grid-template-rows: var(--battle-step-row) var(--battle-head-row) minmax(132px, 1fr) max-content;
    /* さらに低い画面では、文字やカードを潰さずパネル内をスクロールできるようにする。 */
    pointer-events: auto;
  }

  .app.mobile-layout .control-panel.has-pending-battle .battle-result.has-inline-special-choice:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated):not(.final-blow) {
    grid-template-rows: var(--battle-step-row) var(--battle-head-row) max-content minmax(132px, 1fr) max-content;
  }

  .app.mobile-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-stage {
    min-height: 0;
    container-type: size;
  }

  .app.mobile-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) .battle-impact {
    min-height: 0;
  }

  /* 英語の属性アイコンを文字の基線から外し、計算欄と戦士絵の高さを保つ。 */
  .app.mobile-layout .term-attr:lang(en) em {
    display: flex;
    align-items: center;
  }

  .app.mobile-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) :is(.battle-unit-wrap, .battle-weapon-anchor) {
    /* 武器名と間隔を残し、カードの縦横比と武器の重なりを保つ。 */
    width: min(106px, 100%, max(0px, calc((100cqh - var(--battle-weapon-name-space, 18px)) * 2 / 3)));
  }
}

/* スマホ縦では攻撃・ブロックの選択から決着まで枠の上端を固定する。 */
@media (max-width: 620px) and (orientation: portrait) {
  #app.mobile-layout #battlePanel:has(.battle-special-wait-choice-overlay) {
    overflow-y: auto;
  }

  /* 候補を戦士の表示領域に収め、その下の武器説明と重ならないようにする。 */
  .app.mobile-layout .battle-stage .battle-special-wait-choice-overlay {
    inset-block: 0;
    align-content: start;
    overflow-y: auto;
  }

  .app.mobile-layout .battle-special-wait-choice-overlay .battle-special-choice-card {
    flex-basis: clamp(52px, calc((100cqh - 42px) * 2 / 3), 66px);
  }

  .app.mobile-fullscreen-layout .control-panel.has-pending-battle
    .battle-panel:is([data-mode="attack-choice"], [data-mode="attack-call"], [data-mode="block-choice"],
      [data-mode="block-call"], [data-mode="weapon-choice"], [data-mode="processing"], [data-mode="damage-preview"], [data-mode="result"]) {
    /* ミニ詳細の高さは確保し、枠の間隔だけ最大4px詰める。 */
    --mobile-battle-detail-gap: 4px;
    --mobile-battle-gap-saving: clamp(0px,
      calc(var(--mobile-battle-panel-top) - var(--mobile-player-head-height)
        - max(var(--mobile-selection-height), var(--mobile-battle-selection-height, 0px)) - var(--mobile-battle-detail-gap)),
      4px);
  }

  /* 縦フル表示は下の操作列を残すため、候補欄と確定操作の周囲を詰める。 */
  :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-panel {
    padding-block-end: 6px;
  }

  :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-choice-section {
    row-gap: 3px;
  }

  :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-position-group {
    padding-block: 2px;
  }

  :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-position-group.has-candidates .battle-choice-list {
    padding-block-end: 3px;
  }

  :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle .battle-panel[data-mode="attack-choice"] .battle-attack-actions {
    padding-block: 2px;
  }

  /* 決着も同じ枠を使い、内訳が長くても戦士と武器を動かさない。 */
  .app.mobile-layout .control-panel.has-pending-battle
    :is(.battle-panel, .battle-panel > :is(.friend-battle-presentation, .friend-match-content)) >
    .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated):not(.has-inline-special-choice) {
    --battle-head-row: var(--battle-phone-head-row, 52px);
    --battle-phone-row-gap: 7px;
    --battle-phone-layout-row-gap: var(--battle-phone-row-gap);
    --battle-phone-stage-space: calc(100cqh - var(--mobile-battle-gap-saving, 0px) - var(--battle-step-row) - var(--battle-head-row)
      - var(--battle-phone-row-gap) * 3 - var(--battle-phone-details-space, 158px));
    height: auto;
    min-height: 100%;
    row-gap: var(--battle-phone-layout-row-gap);
    /* 戦士と武器の高さを内訳の実寸と分け、収まらない内訳はパネル内でスクロールする。 */
    grid-template-rows: var(--battle-step-row) var(--battle-head-row)
      clamp(132px, var(--battle-phone-stage-space), 195px) max-content;
  }

  .app.mobile-layout:lang(en) {
    --battle-phone-head-row: 64px;
    --battle-weapon-name-space: 32px;
  }

  @media (max-width: 350px) {
    .app.mobile-layout:lang(en) {
      --battle-phone-head-row: 80px;
      --battle-phone-compact-row-gap: 2px;
    }
  }

  .app.mobile-safari-layout:lang(en) {
    /* 全段階で結果文2行分を取り、武器名は1行のままにする。 */
    --battle-phone-head-row: 64px;
    --battle-weapon-name-space: 18px;
    --battle-phone-compact-row-gap: 3px;
  }

  @container battle-viewport (max-height: 440px) {
    .app.mobile-layout .battle-result {
      --battle-phone-details-space: 138px;
    }
  }

  @container battle-viewport (max-height: 500px) {
    .app.mobile-layout .control-panel.has-pending-battle
      :is(.battle-panel, .battle-panel > :is(.friend-battle-presentation, .friend-match-content)) >
      .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated):not(.has-inline-special-choice) {
      /* 戦士絵の割当はそのまま、内訳が入りやすいよう行間と上下の余白を詰める。 */
      --battle-phone-layout-row-gap: var(--battle-phone-compact-row-gap, 3px);
      padding-block: 3px;
    }
  }
}

/* 端末名やウィンドウ高ではなく、戦闘パネルの残り高に応じて余白を詰める。 */
@container battle-viewport (max-height: 440px) {
  body.mobile-landscape-layout .app.mobile-landscape-layout
    .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated):not(.final-blow) {
    gap: 2px;
    padding: 2px;
  }

  .battle-calc-content {
    gap: 4px;
  }

  .clash-gauge {
    gap: 3px;
    min-height: 42px;
  }

  .clash-labels strong {
    font-size: 15px;
  }

  .clash-track {
    height: 22px;
  }

  .battle-formula-grid {
    gap: 4px;
  }

  .formula-side {
    gap: 3px 6px;
    padding: 4px 6px;
  }

  .formula-title > span {
    font-size: 9.5px;
  }

  .formula-title strong {
    font-size: 18px;
  }

  .formula-line {
    gap: 2px;
  }

  .formula-term {
    gap: 1px;
    padding: 2px 3px;
  }

  .formula-term em {
    font-size: 7.5px;
  }

  .formula-term strong,
  .formula-total {
    font-size: 9.5px;
  }
}

/* 幅広iPhoneでは通常盤面と戦闘候補の拡大率を揃える。 */
@media (min-width: 400px) and (max-width: 620px) and (orientation: portrait) {
  .control-panel.has-pending-battle .battle-panel {
    --mobile-battle-route-card-width: clamp(76px, 9dvh, 84px);
    --mobile-battle-candidate-card-width: clamp(74px, 8.6dvh, 80px);
  }

  .battle-step-trail span {
    font-size: 10px;
  }

  .battle-attack-head strong,
  .battle-weapon-head strong,
  .battle-block-head strong {
    font-size: 14.5px;
  }

  .battle-choice-card-info strong {
    font-size: 9.5px;
  }
}

/* タブレット縦画面は計算欄を確保し、残り高で戦士と武器を同じ倍率にする。 */
@media (min-width: 621px) and (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  .control-panel.has-pending-battle .battle-panel {
    /* 選択・ボタン・演出・計算欄を同じ幅のウィンドウに収める。 */
    --tablet-battle-panel-width: min(680px, calc(var(--app-usable-width) - (var(--mobile-battle-panel-inset) * 2)));
    width: var(--tablet-battle-panel-width);
    left: calc(var(--app-viewport-offset-left) + var(--app-safe-left) + (var(--app-usable-width) - var(--tablet-battle-panel-width)) / 2);
    --battle-step-row: 30px;
    --mobile-battle-route-card-width: clamp(92px, 12dvh, 164px);
    --mobile-battle-candidate-card-width: clamp(88px, 11dvh, 150px);
    padding: 4px 11px 12px;
  }

  .battle-step-trail {
    gap: 4px;
  }

  .battle-step-trail span {
    font-size: clamp(13px, 1.3dvh, 17px);
  }

  .battle-attack-panel,
  .battle-block-panel,
  .battle-weapon-panel {
    gap: 9px;
    padding: 7px 10px 11px;
  }

  .battle-attack-head strong,
  .battle-weapon-head strong,
  .battle-block-head strong {
    font-size: clamp(18px, 2dvh, 26px);
  }

  .battle-attack-head span,
  .battle-weapon-head span,
  .battle-block-head span,
  .battle-attack-head small,
  .battle-weapon-head small,
  .battle-block-head small {
    font-size: clamp(14px, 1.45dvh, 19px);
  }

  .battle-attack-position-columns {
    grid-template-columns:
      minmax(108px, var(--attack-front-track, 1fr))
      minmax(108px, var(--attack-back-track, 1fr));
    gap: 7px;
  }

  @media (max-height: 1100px) {
    #battlePanel[data-mode="attack-choice"] .battle-attack-panel {
      padding-block-end: 7px;
    }

    #battlePanel[data-mode="attack-choice"] .battle-attack-position-group {
      padding-block: 3px;
    }

    #battlePanel[data-mode="attack-choice"] .battle-attack-actions {
      padding-block: 2px;
    }
  }

  .battle-choice-card,
  .battle-blocker-choice-section .battle-choice-card {
    flex-basis: var(--mobile-battle-candidate-card-width);
  }

  .battle-choice-card-info {
    right: 4px;
    bottom: 4px;
    left: 4px;
    padding: 4px;
  }

  .battle-choice-card-info strong {
    font-size: clamp(12px, 1.35dvh, 18px);
  }

  .battle-choice-card-info span,
  .battle-choice-card-info small {
    font-size: clamp(11px, 1.15dvh, 15px);
  }

  .battle-choice-estimate strong {
    font-size: 16px;
  }

  .battle-special-wait-choice-head strong {
    font-size: 14px;
  }

  .battle-special-wait-choice-head span,
  .battle-special-wait-skip {
    font-size: 12px;
  }

  .battle-weapon-wait {
    min-height: 88px;
    font-size: 14px;
  }

  .battle-result .battle-impact {
    --battle-impact-badge-size: 58px;
    /* 円を中央に収め、戦士と武器の列幅を保つ。 */
    grid-template-columns: minmax(0, 1fr);
    font-size: 15px;
  }

  .final-blow .battle-impact > span {
    --finish-impact-offset-x: 0px;
    width: 72px;
    height: 72px;
    font-size: 18px;
  }

  .clash-labels {
    font-size: clamp(14px, 1.5dvh, 20px);
  }

  .clash-labels strong {
    font-size: clamp(22px, 2.2dvh, 28px);
  }

  .clash-damage {
    max-width: 150px;
    font-size: 12px;
  }

  .clash-track {
    height: 32px;
  }

  .formula-title > span {
    font-size: clamp(13px, 1.5dvh, 19px);
  }

  .formula-title strong {
    font-size: 23px;
  }

  .formula-term em {
    font-size: clamp(12px, 1.3dvh, 17px);
  }

  .formula-term strong,
  .formula-total {
    font-size: clamp(14px, 1.5dvh, 20px);
  }

  .app.mobile-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) {
    --battle-head-row: clamp(64px, 6.5dvh, 90px);
  }

  .app.mobile-layout .battle-head-stack strong {
    font-size: clamp(18px, 2dvh, 26px);
  }

  .app.mobile-layout .battle-head-stack span {
    font-size: clamp(13px, 1.4dvh, 18px);
  }

  .app.mobile-layout .battle-result:not(.direct-attack):not(.battle-interrupt):not(.battle-process-terminated) :is(.battle-unit-wrap, .battle-weapon-anchor) {
    --tablet-battle-art-width: min(calc(var(--mobile-layout-width) * 0.25), max(64px, calc((100cqh - 34px) * 2 / 3)));
    width: min(var(--tablet-battle-art-width), 100%);
  }

  .app.mobile-layout .battle-weapon-anchor {
    --tablet-battle-art-width: 106px;
    --battle-magic-circle-hand-offset: calc(var(--tablet-battle-art-width) * 6 / 106);
    --battle-magic-spell-impact-x: calc(var(--tablet-battle-art-width) * 82 / 106);
    --battle-magic-spell-cast-y: calc(var(--tablet-battle-art-width) * -8 / 106);
  }

  .app.mobile-layout .battle-weapon-card {
    width: calc(var(--tablet-battle-art-width) * 54 / 106);
    bottom: calc(var(--tablet-battle-art-width) * 28 / 106);
  }

  .app.mobile-layout .battle-weapon-card.has-card-art {
    width: calc(var(--tablet-battle-art-width) * 90 / 106);
    height: auto;
    aspect-ratio: 90 / 130;
    bottom: calc(var(--tablet-battle-art-width) * 16 / 106);
  }

  .app.mobile-layout .battle-weapon-left.has-card-art {
    right: calc(var(--tablet-battle-art-width) * -50 / 106);
  }

  .app.mobile-layout .battle-weapon-right.has-card-art {
    left: calc(var(--tablet-battle-art-width) * -50 / 106);
  }

  .app.mobile-layout .battle-weapon-card.battle-magic-book.has-card-art {
    width: calc(var(--tablet-battle-art-width) * 84 / 106);
    aspect-ratio: 84 / 118;
    bottom: calc(var(--tablet-battle-art-width) * 20 / 106);
  }

  .app.mobile-layout .battle-weapon-card.battle-magic-spell.has-card-art {
    width: calc(var(--tablet-battle-art-width) * 112 / 106);
    aspect-ratio: 112 / 136;
    bottom: calc(var(--tablet-battle-art-width) * 8 / 106);
  }

  .app.mobile-layout .battle-weapon-left.battle-magic-spell.has-card-art {
    right: calc(var(--tablet-battle-art-width) * -60 / 106);
  }

  .app.mobile-layout .battle-weapon-right.battle-magic-spell.has-card-art {
    left: calc(var(--tablet-battle-art-width) * -60 / 106);
  }

  .app.mobile-layout .battle-magic-circle {
    width: calc(var(--tablet-battle-art-width) * 112 / 106);
    height: calc(var(--tablet-battle-art-width) * 112 / 106);
    margin: calc(var(--tablet-battle-art-width) * -56 / 106) 0 0 calc(var(--tablet-battle-art-width) * -56 / 106);
  }

  .app.mobile-layout .battle-magic-circle-spell {
    width: calc(var(--tablet-battle-art-width) * 124 / 106);
    height: calc(var(--tablet-battle-art-width) * 124 / 106);
    margin: calc(var(--tablet-battle-art-width) * -62 / 106) 0 0 calc(var(--tablet-battle-art-width) * -62 / 106);
  }

  .app.mobile-layout .battle-card-name {
    font-size: clamp(10px, calc((var(--tablet-battle-art-width, 106px) - 24px) / 7), 24px);
  }

  .app.mobile-layout .battle-weapon-name {
    font-size: clamp(12px, 1.35dvh, 18px);
  }
}

/* 端末ごとの密度に合わせ、進行表示と主見出しの起点を各段階で共通にする。 */
#battlePanel {
  --battle-content-top: 8px;
  --battle-content-inline: 8px;
  --battle-heading-inset: 6px;
  --battle-heading-gap: calc(3px + var(--battle-heading-inset));
  --battle-choice-flow-gap: 10px;
  --battle-result-flow-gap: 8px;
  --battle-heading-size: 18px;
  --battle-heading-copy-size: 12px;
  --battle-heading-copy-line: calc(var(--battle-heading-copy-size) * 7 / 6);
  --battle-heading-reserve: calc(var(--battle-heading-size) * 1.2 + var(--battle-heading-copy-line) * 2 + 2px);
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel {
  --battle-heading-reserve: calc(var(--battle-heading-size) * 1.2 + var(--battle-heading-copy-line) + 2px);
}

@media (max-width: 620px) and (orientation: portrait) {
  .app.mobile-layout #battlePanel {
    --battle-content-top: 3px;
    --battle-content-inline: 7px;
    --battle-choice-flow-gap: 6px;
    --battle-heading-reserve: 52px;
  }

  @media (max-height: 720px) {
    :where(.app:not(.mobile-safari-layout)) #battlePanel[data-mode="attack-choice"] .battle-attack-panel {
      --battle-choice-flow-gap: 4px;
    }

    :where(.app:not(.mobile-safari-layout)) .control-panel.has-pending-battle #battlePanel[data-mode="attack-choice"] .battle-attack-position-group.has-candidates .battle-choice-list {
      padding-block-end: 2px;
    }
  }
}

@media (min-width: 621px) and (max-width: 1100px) and (max-height: 1400px) and (orientation: portrait) and (any-pointer: coarse) {
  .app.mobile-layout #battlePanel {
    --battle-content-top: 5px;
    --battle-content-inline: 7px;
    --battle-choice-flow-gap: 9px;
    --battle-result-flow-gap: 7px;
    --battle-heading-size: clamp(18px, 2dvh, 26px);
    --battle-heading-copy-size: clamp(13px, 1.4dvh, 18px);
  }
}

.app.mobile-landscape-layout #battlePanel {
  --battle-content-top: 5px;
  --battle-content-inline: 5px;
  --battle-choice-flow-gap: 4px;
  --battle-result-flow-gap: 5px;
  --battle-heading-size: var(--landscape-text-xl);
  --battle-heading-copy-size: var(--landscape-text-md);
}

@media (max-height: 620px) and (orientation: landscape) {
  .app.mobile-landscape-layout #battlePanel {
    --battle-content-top: 2px;
    --battle-content-inline: 2px;
    --battle-heading-inset: 4px;
    --battle-heading-gap: calc(2px + var(--battle-heading-inset));
    --battle-result-flow-gap: 2px;
  }
}

#battlePanel:where([data-mode="attack-choice"], [data-mode="attack-call"], [data-mode="block-choice"], [data-mode="block-call"], [data-mode="weapon-choice"])
  :is(.battle-attack-panel, .battle-block-panel, .battle-weapon-panel) {
  padding-block-start: var(--battle-content-top);
  padding-inline: var(--battle-content-inline);
  row-gap: var(--battle-choice-flow-gap);
}

#battlePanel :is(.battle-attack-head, .battle-block-head, .battle-weapon-head):not(.battle-effect-target-head) {
  margin-block-start: calc(var(--battle-heading-gap) - var(--battle-choice-flow-gap));
  min-height: calc(var(--battle-heading-reserve) - var(--battle-heading-inset));
  align-content: start;
  row-gap: 0;
}

/* 段階名は進行表示へ集約し、宣言では段階名自体を見出しにする。 */
#battlePanel :is(.battle-attack-head:not(.battle-attack-call-head, .battle-effect-target-head), .battle-block-head, .battle-weapon-head) > span {
  display: none;
}

#battlePanel :is(.battle-attack-head:not(.battle-attack-call-head, .battle-effect-target-head), .battle-block-head, .battle-weapon-head) > strong,
#battlePanel .battle-attack-call-head > span {
  margin-block-end: 2px;
  color: #aee7ff;
  font-size: var(--battle-heading-size);
  font-weight: 700;
  line-height: 1.2;
}

#battlePanel :is(.battle-attack-head, .battle-block-head, .battle-weapon-head):not(.battle-effect-target-head) > small,
#battlePanel .battle-attack-call-head > strong {
  color: #cbc5b4;
  font-size: var(--battle-heading-copy-size);
  font-weight: 400;
  line-height: var(--battle-heading-copy-line);
}

#battlePanel .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) {
  --battle-result-row-gap: var(--battle-phone-layout-row-gap, var(--battle-result-flow-gap));
  padding-block-start: var(--battle-content-top);
  padding-inline: var(--battle-content-inline);
  row-gap: var(--battle-result-row-gap);
}

#battlePanel .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) > .battle-head-stack {
  margin-block-start: calc(var(--battle-heading-gap) - var(--battle-result-row-gap));
  /* 見出しだけを下げ、戦士と武器を載せる行の位置は保つ。 */
  height: auto;
  min-height: 0;
  max-height: none;
}

#battlePanel .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated))
  :is(.battle-process-head, .battle-correction-head, .battle-result-head) {
  min-height: 0;
  row-gap: 2px;
}

#battlePanel .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated, .final-blow))
  :is(.battle-process-head, .battle-correction-head, .battle-result-head) > strong {
  font-size: var(--battle-heading-size);
  font-weight: 700;
}

#battlePanel .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated))
  :is(.battle-process-head, .battle-correction-head, .battle-result-head) > span {
  margin-block-start: 0;
  font-size: var(--battle-heading-copy-size);
  line-height: var(--battle-heading-copy-line);
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel
  .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) {
  --battle-head-row: 51px;
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel
  .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) > .battle-head-stack {
  /* 前後の間隔を一部使い、本文が2行になっても戦士と武器を押し下げない。 */
  margin-block: -3px -4px;
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel
  .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated))
  :is(.battle-process-head, .battle-correction-head, .battle-result-head) {
  /* 見出しと説明を一緒に中央へ寄せ、本文が折り返してもステージの位置を保つ。 */
  min-block-size: 100%;
  align-content: safe center;
  row-gap: 3px;
  padding-block-end: 4px;
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel
  .battle-result.final-blow:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) .battle-result-head > strong {
  line-height: 1;
}

.app:not(.mobile-layout, .mobile-landscape-layout, .native-app-layout) #battlePanel
  .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated))
  :is(.battle-process-head, .battle-correction-head, .battle-result-head) > span {
  /* 長文でも見出しと戦闘位置を保ち、3行目以降は本文内で読めるようにする。 */
  max-block-size: calc(var(--battle-heading-copy-line) * 2);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 620px) and (orientation: portrait) {
  #app.mobile-safari-layout:lang(en) .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) .battle-weapon-name {
    max-inline-size: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 中央の60pxのうち左右26pxずつを長い武器名に使い、中央に8px残す。 */
  #app.mobile-safari-layout:lang(en) .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) .battle-actor {
    grid-template-columns: minmax(0, 1fr);
  }

  #app.mobile-safari-layout:lang(en) .battle-result:where(:not(.direct-attack, .battle-interrupt, .battle-process-terminated)) .battle-weapon-name {
    width: max-content;
    min-inline-size: 100cqw;
    max-inline-size: calc(100cqw + 26px);
    justify-self: var(--battle-weapon-name-align);
  }

  #app.mobile-safari-layout:lang(en) .battle-side-left {
    --battle-weapon-name-align: start;
  }

  #app.mobile-safari-layout:lang(en) .battle-side-right {
    --battle-weapon-name-align: end;
  }
}
