/* 盤面、レーン、カード、手札、コスト、ドラッグと選択状態。 */

/* 前衛・後衛の表示を読みやすくし、レーンやカードの位置は維持する。 */
#app .lane-label {
  color: #eadfbe;
  border-color: #b5a27352;
  background: linear-gradient(180deg, #20372de8, #11271fe8);
}

.board {
  display: grid;
  gap: 8px;
  background: transparent;
}

.lane {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: stretch;
  gap: 8px;
  overflow: visible;
}

.lane-label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  writing-mode: vertical-rl;
  border: 1px solid rgba(242, 219, 157, 0.18);
  border-radius: var(--ui-radius-md);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 238, 174, 0.055), transparent 52%),
    rgba(17, 21, 17, 0.64);
  font-weight: 800;
  letter-spacing: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -8px 14px rgba(0, 0, 0, 0.12);
}

.unit-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, var(--board-card-width));
  grid-auto-rows: var(--board-card-height);
  justify-content: start;
  align-items: start;
  column-gap: 16px;
  row-gap: 8px;
  min-height: var(--unit-row-reserved-height);
  padding: 8px 8px 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  box-shadow: none;
}

.unit-row::before,
.unit-row::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: inherit;
}

.unit-row::before {
  inset: 0;
  background: transparent;
}

.unit-row::after {
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 1px;
  background: transparent;
}

.unit-row > * {
  position: relative;
  z-index: 1;
}

.front-row {
  background: var(--field-front-bg);
  box-shadow:
    var(--field-contact-inset-shadow, inset 0 0 0 transparent),
    inset 0 1px 0 rgba(255, 238, 174, 0.05),
    inset 0 -18px 28px var(--field-front-depth-shadow);
}

.back-row {
  background: var(--field-back-bg);
  box-shadow:
    var(--field-contact-inset-shadow, inset 0 0 0 transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    inset 0 -10px 22px var(--field-back-depth-shadow);
}

@media (min-width: 621px) {
  :root {
    --field-front-bg:
      radial-gradient(ellipse at 50% 106%, rgba(255, 238, 174, 0.09), transparent 58%),
      radial-gradient(ellipse at 50% 104%, var(--field-front-glow), transparent 70%),
      radial-gradient(circle at 18% 42%, rgba(121, 196, 138, 0.13), transparent 44%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%, rgba(0, 0, 0, 0.14)),
      linear-gradient(90deg, rgba(60, 111, 82, 0.36), rgba(46, 83, 63, 0.13) 62%, rgba(12, 16, 14, 0.08)),
      rgba(18, 27, 21, 0.26);
    --field-back-bg:
      radial-gradient(ellipse at 50% 112%, rgba(174, 231, 255, 0.045), transparent 64%),
      radial-gradient(ellipse at 50% 104%, var(--field-back-glow), transparent 72%),
      radial-gradient(circle at 18% 42%, rgba(133, 211, 204, 0.085), transparent 44%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.026), transparent 42%, rgba(0, 0, 0, 0.09)),
      linear-gradient(90deg, rgba(66, 82, 116, 0.25), rgba(51, 65, 92, 0.095) 62%, rgba(12, 16, 14, 0.065)),
      rgba(20, 25, 34, 0.2);
  }

  .lane {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .lane-label {
    position: absolute;
    top: 8px;
    left: 10px;
    z-index: 4;
    min-width: 54px;
    height: 24px;
    padding: 0 10px;
    writing-mode: horizontal-tb;
    border-radius: 999px;
    pointer-events: none;
  }

  .unit-row {
    border-color: rgba(242, 219, 157, 0.08);
    padding-left: 78px;
  }

  .front-row {
    box-shadow:
      var(--field-contact-inset-shadow, inset 0 0 0 transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      inset 0 0 28px rgba(118, 205, 141, 0.055),
      inset 0 -20px 32px rgba(0, 0, 0, 0.16);
  }

  .back-row {
    box-shadow:
      var(--field-contact-inset-shadow, inset 0 0 0 transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.035),
      inset 0 0 24px rgba(118, 188, 230, 0.045),
      inset 0 -22px 34px rgba(0, 0, 0, 0.18);
  }
}

@media (orientation: landscape) {
  body:not(.mobile-layout):not(.mobile-landscape-layout) .player-panel .board {
    gap: 2px;
    padding-top: 6px;
    padding-bottom: 2px;
  }

  body:not(.mobile-layout):not(.mobile-landscape-layout) .player-panel .cost-zone {
    border-top-width: 0;
    padding-top: 4px;
    padding-bottom: 6px;
  }
}

.cards {
  display: flex;
  flex-wrap: wrap;
  column-gap: 16px;
  row-gap: 8px;
  min-height: 68px;
  padding: 8px 0 0 10px;
}

.hand,
.cost {
  flex-wrap: nowrap;
  column-gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-left: 8px;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.cost {
  height: var(--compact-row-height);
  min-height: var(--compact-row-height);
  max-height: var(--compact-row-height);
  align-items: flex-start;
}

.hand .card,
.cost .card {
  flex: 0 0 var(--compact-card-min-width);
  width: var(--compact-card-min-width);
  min-width: var(--compact-card-min-width);
  max-width: var(--compact-card-min-width);
  height: var(--compact-card-height);
  min-height: var(--compact-card-height);
  max-height: var(--compact-card-height);
  padding: 6px;
}

.card.draggable-card {
  cursor: grab;
}

.card,
.unit,
.battle-choice-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.card img,
.unit img,
.battle-choice-card img {
  -webkit-user-drag: none;
}

.card *,
.unit *,
.battle-choice-card * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/*
 * カード内部は表示専用。子要素がカード枠からはみ出しても、
 * その領域まで親buttonのタップ判定を広げない。
 */
.card > *,
.unit > * {
  pointer-events: none;
}

.card.draggable-card:active {
  cursor: grabbing;
}

/* 横へは手札スクロール、縦へは長押しを待たない配置操作。 */
body.mobile-layout .hand .touch-deploy-card,
body.mobile-landscape-layout .hand .touch-deploy-card,
body.mobile-landscape-layout .cost .touch-deploy-card,
body.mobile-layout .zone.board .draggable-unit,
body.mobile-landscape-layout .zone.board .draggable-unit {
  touch-action: pan-x pinch-zoom;
}

/* 縦画面のコストは縦スクロールを残し、横へ引き出して武器を運ぶ。 */
body.mobile-layout .cost .touch-deploy-card {
  touch-action: pan-y pinch-zoom;
}

body > .card.touch-card-drag-ghost,
body > .unit.touch-card-drag-ghost {
  position: fixed;
  z-index: 10000;
  width: var(--touch-drag-width) !important;
  min-width: var(--touch-drag-width) !important;
  max-width: var(--touch-drag-width) !important;
  height: var(--touch-drag-height) !important;
  min-height: var(--touch-drag-height) !important;
  max-height: var(--touch-drag-height) !important;
  margin: 0;
  transform: translate(-50%, -100%);
  pointer-events: none;
  opacity: 0.92;
  box-shadow: 0 5px 18px #0008;
}

.touch-drop-ready {
  outline: 2px dashed #77d8bb;
  outline-offset: -3px;
}

.touch-drop-over {
  outline: 3px solid #b1ffdc;
  outline-offset: -3px;
  box-shadow: inset 0 0 18px #77d8bb55;
}

.unit.draggable-unit {
  cursor: grab;
}

.unit.draggable-unit:active {
  cursor: grabbing;
}

@media (hover: hover) and (pointer: fine) {
  .hand .card {
    transition:
      border-color 120ms ease,
      box-shadow 120ms ease,
      filter 120ms ease;
  }

  .card.draggable-card:hover,
  .unit.draggable-unit:hover {
    border-color: rgba(255, 225, 154, 0.52);
    filter: brightness(1.045) saturate(1.04);
    box-shadow:
      var(--shadow-card-polished),
      0 0 0 1px rgba(255, 225, 154, 0.18),
      0 0 18px rgba(255, 225, 154, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 -18px 24px rgba(0, 0, 0, 0.18);
  }
}

/* 縦配置のboardはdisplay: contents。背景や親の枠に頼らず、各列の内側へ合図を重ねる。 */
.lane.touch-drop-ready::after,
.lane.battlefield-drop-over::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: 6;
  pointer-events: none;
  border: 2px dashed #77d8bb;
  border-radius: var(--ui-radius-md);
  background: rgba(119, 216, 187, 0.06);
}

.lane.touch-drop-over::after,
.lane.battlefield-drop-over::after {
  border: 3px solid #ffe088;
  background: linear-gradient(90deg, rgba(255, 224, 136, 0.18), rgba(119, 216, 187, 0.08));
  box-shadow: inset 0 0 18px rgba(255, 224, 136, 0.25);
}

/* 親の枠は列の内側の合図と重複させない。コスト・武器パネルの強調は共通のまま。 */
.lane.touch-drop-ready,
.lane.touch-drop-over {
  outline: none;
  box-shadow: none;
}

/* レベルアップは列全体ではなく、重ね先の戦士を示す。 */
.unit.touch-drop-ready {
  outline: 2px dashed #77d8bb;
  outline-offset: -2px;
}

.unit.touch-drop-over,
.unit.battlefield-drop-over {
  outline: 3px solid #ffe088;
  outline-offset: -3px;
  box-shadow: inset 0 0 18px rgba(255, 224, 136, 0.3), 0 0 14px rgba(255, 224, 136, 0.55);
  filter: brightness(1.12);
}

.lane.lane-drag-over .unit-row {
  outline: 2px solid rgba(234, 107, 107, 0.95);
  outline-offset: 3px;
  background:
    linear-gradient(90deg, rgba(234, 107, 107, 0.18), rgba(245, 211, 111, 0.08)),
    rgba(46, 83, 63, 0.35);
}

.cost-zone.cost-drag-over .cost {
  outline: 2px solid rgba(245, 211, 111, 0.9);
  outline-offset: 2px;
  background: rgba(245, 211, 111, 0.12);
}

.hand .name,
.cost .name {
  min-height: 30px;
  color: #fff3cf;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  display: -webkit-box;
  max-height: 44px;
  overflow: hidden;
  overflow-wrap: normal;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.74);
  word-break: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* 手札/コストの長いカード名だけ詰め、カード寸法は変えない。 */
.hand .card.dense-surface-name .name,
.cost .card.dense-surface-name .name {
  font-size: 11.2px;
  line-height: 1.12;
}

.hand .card.triple-surface-name .name,
.cost .card.triple-surface-name .name {
  line-height: 1.06;
}

.hand .card.triple-surface-name .stat-line,
.cost .card.triple-surface-name .stat-line {
  margin-top: 2px;
}

.hand .stat-line,
.hand .tag-line,
.hand .effect-line,
.cost .stat-line,
.cost .tag-line,
.cost .effect-line {
  margin-top: 4px;
  font-size: 10.5px;
  line-height: 1.18;
}

.hand .stat-line,
.cost .stat-line {
  white-space: nowrap;
}

.hand .tag-line,
.cost .tag-line {
  min-height: 18px;
  gap: 3px;
}

.hand .trait-badge,
.cost .trait-badge {
  min-height: 16px;
  padding: 1px 4px;
  font-size: 10px;
}

.hand .effect-line,
.cost .effect-line {
  max-height: 42px;
  -webkit-line-clamp: 3;
}

.card,
.unit {
  position: relative;
  border: 1px solid rgba(242, 219, 157, 0.24);
  border-radius: var(--compact-card-corner-radius);
  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.055), transparent 38%),
    #292e28;
  color: var(--text);
  text-align: left;
  overflow: visible;
  box-shadow:
    var(--shadow-card-polished),
    0 0 0 1px var(--card-edge-dark),
    inset 0 1px 0 var(--card-edge-light),
    inset 0 -18px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(0) scale(1);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease,
    transform 140ms ease;
  will-change: transform, filter;
}

.hand .card {
  transform:
    translateY(calc(var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)))
    rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
    scale(1);
  transform-origin: 50% 118%;
}

.hand .card:active:not(:disabled) {
  transform:
    translateY(calc(var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)))
    rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
    scale(1);
}

.hand .card + .card {
  margin-left: calc(-1 * var(--hand-card-overlap, 0px));
}

.hand {
  justify-content: center;
}

@media (min-width: 621px) {
  .app:not(.mobile-fullscreen-layout):not(.mobile-safari-layout) .hand {
    margin-top: -5px;
    padding-top: 13px;
  }

  .app:not(.mobile-fullscreen-layout):not(.mobile-safari-layout) .hand .card.selected {
    z-index: 9;
  }

  .app:not(.mobile-fullscreen-layout):not(.mobile-safari-layout) .hand .card.selected .level-badge {
    z-index: 10;
  }
}

@supports (justify-content: safe center) {
  .hand {
    justify-content: safe center;
  }
}

.cost {
  justify-content: flex-start;
}

.cost .card + .card {
  margin-left: calc(-1 * var(--cost-card-overlap-x, 0px));
}

.cost .card {
  box-shadow:
    var(--shadow-card-polished),
    2px calc(5px + var(--cost-stack-shadow-y, 0px)) 10px rgba(0, 0, 0, 0.2),
    0 0 0 1px var(--card-edge-dark),
    inset 0 1px 0 var(--card-edge-light),
    inset 0 -18px 24px rgba(0, 0, 0, 0.2);
}

/* タッチ操作では選択のたびに画像全体の色調フィルターを切り替えない。 */
@media (hover: hover) and (pointer: fine) {
  .cost .card:not(.selected):not(.tutorial-highlight) {
    filter: saturate(0.96) brightness(0.98);
  }
}

/* 一度公開された裏向きコストは、正体を見せたまま半透明のカード裏で区別する。 */
.cost .card.publicly-known-face-down {
  position: relative;
  overflow: hidden;
}

.cost .card.publicly-known-face-down::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(12, 15, 22, 0.08), rgba(12, 15, 22, 0.28)),
    var(--card-back);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.52;
  pointer-events: none;
}

.unit.side-left {
  --unit-forward-x: 5px;
  --unit-brace-x: -3px;
  --unit-block-x: 4px;
  --unit-block-x-soft: 1px;
}

.unit.side-right {
  --unit-forward-x: -5px;
  --unit-brace-x: 3px;
  --unit-block-x: -4px;
  --unit-block-x-soft: -1px;
}

.unit.unit-visual-call {
  z-index: 18;
  overflow: visible;
  animation: unit-call-pop 360ms ease-out both;
}

.unit.vanguard-face-down {
  cursor: default;
}

.unit.unit-visual-vanguard-reveal {
  animation: unit-vanguard-reveal 980ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.unit.unit-visual-level-up {
  z-index: 20;
  overflow: visible;
  animation: unit-level-up-lift 440ms ease-out both;
}

.unit.unit-visual-level-up .level-badge {
  animation: unit-level-up-badge 440ms ease-out both;
}

.unit.unit-visual-position {
  animation: unit-position-pulse 620ms ease-out both;
}

.unit.unit-visual-attack-call {
  animation: unit-attack-call 700ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.unit.unit-visual-target-call {
  animation: unit-target-call 700ms ease-out both;
}

.unit.unit-visual-block {
  animation: unit-block-step 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.unit.unit-visual-call,
.unit.unit-visual-vanguard-reveal,
.unit.unit-visual-level-up,
.unit.unit-visual-position,
.unit.unit-visual-attack-call,
.unit.unit-visual-target-call,
.unit.unit-visual-block,
.unit.unit-visual-level-up .level-badge {
  animation-delay: var(--unit-visual-delay, 0ms);
}

.unit.unit-visual-effect-source,
.card.card-visual-effect-source {
  animation: source-card-lift 920ms ease-out both;
}

.unit.unit-visual-hp-damage .hpbar {
  box-shadow:
    0 0 0 1px rgba(255, 112, 88, 0.42),
    0 0 10px rgba(255, 112, 88, 0.28);
}

.unit .unit-effect-result-frame {
  position: absolute;
  inset: 1px;
  z-index: 12;
  border-radius: inherit;
  pointer-events: none;
  border: 2px solid #a9eaff;
  box-shadow: inset 0 0 9px rgba(108, 212, 244, 0.45);
  animation: effect-target-confirm 1000ms ease-out calc(90ms + var(--effect-result-delay, 0ms)) both;
}

.unit .unit-damage-prevented-label {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 36%;
  z-index: 13;
  padding: 0.3em 0.1em;
  border: 1px solid #bcefff;
  border-radius: 0.5em;
  background: rgba(18, 58, 75, 0.94);
  color: #e6faff;
  font-size: clamp(7px, calc(var(--board-card-width, 118px) * 0.1), 17px);
  font-weight: 900;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(108, 212, 244, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .unit .unit-effect-result-frame {
    animation-duration: 160ms;
  }
}

.unit.unit-visual-hp-damage .hpbar-current {
  animation: hpbar-current-decrease 820ms cubic-bezier(0.2, 0.74, 0.18, 1) both;
}

.unit.unit-visual-battle-hp-damage .hpbar-current {
  animation-name: hpbar-battle-current-decrease;
}

.unit.unit-visual-hp-recovery .hpbar {
  box-shadow:
    0 0 0 1px rgba(236, 255, 245, 0.52),
    0 0 12px rgba(188, 255, 220, 0.34);
}

.unit.unit-visual-hp-recovery .hpbar-current {
  animation: hpbar-current-increase 820ms cubic-bezier(0.2, 0.74, 0.18, 1) both;
}

.unit.unit-visual-rested-change .rest-badge {
  animation: rest-badge-pop 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.unit.unit-zone-ghost:disabled {
  cursor: default;
  opacity: 1;
}

.unit.unit-zone-ghost.unit-visual-battle-destroyed {
  pointer-events: none;
  animation: board-unit-battle-destroyed var(--unit-zone-ghost-duration, 1900ms) ease-out both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
  filter: saturate(0.65) brightness(0.78);
  transform-origin: 50% 78%;
  will-change: opacity, transform, filter;
}

.unit.unit-zone-ghost.unit-visual-battle-destroyed:not(.unit-battle-hp-pending) .hpbar-current {
  width: 0% !important;
  animation: none;
  transition: none;
}

.unit.unit-zone-ghost.unit-visual-battle-destroyed:not(.unit-battle-hp-pending) .hpbar-trail {
  display: none;
}

.card.card-visual-draw {
  animation: card-draw-pop 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: 110ms;
}

.hand .card.card-visual-draw {
  animation: hand-card-draw-pop 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: 110ms;
}

.card.card-visual-cost {
  animation: card-cost-place 280ms ease-out both;
}

.card.card-visual-progress-ready .level-badge {
  z-index: 9;
  animation: progress-level-ready 720ms ease-out both;
}

.card.card-visual-progress-blocked .level-badge {
  z-index: 9;
  animation: progress-level-blocked 720ms ease-out both;
}

.card.cost-set-cancelable {
  border-color: rgba(116, 206, 160, 0.95);
  box-shadow:
    0 0 0 2px rgba(116, 206, 160, 0.42),
    0 0 16px rgba(116, 206, 160, 0.22);
}

.card.cost-set-cancelable::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 45%, rgba(116, 206, 160, 0.2), transparent 58%),
    linear-gradient(135deg, rgba(116, 206, 160, 0.14), transparent 52%);
  animation: cost-set-cancelable-pulse 1800ms ease-in-out infinite;
}

.card.card-side-left {
  --card-zone-out-x: 4px;
  --card-zone-out-y: -5px;
  --card-zone-in-x: 4px;
}

.card.card-side-right {
  --card-zone-out-x: -4px;
  --card-zone-out-y: -5px;
  --card-zone-in-x: -4px;
}

.card.card-visual-weapon-out {
  pointer-events: none;
  animation: card-weapon-zone-out var(--weapon-zone-out-ms, 180ms) ease-in both;
}

.card.card-visual-weapon-return {
  animation: card-weapon-zone-return var(--weapon-zone-return-ms, 360ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.card.card-visual-effect-break {
  z-index: 14;
  pointer-events: none;
  transform-origin: 50% 58%;
  animation: card-effect-break 980ms cubic-bezier(0.18, 0.86, 0.22, 1) both;
}

.card.card-visual-effect-break .effect-break-label {
  position: absolute;
  top: 38%;
  left: 50%;
  z-index: 12;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border: 1px solid rgba(255, 222, 172, 0.9);
  border-radius: 999px;
  background: rgba(92, 31, 24, 0.94);
  color: #fff0cf;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 14px rgba(255, 104, 72, 0.46);
  animation: effect-break-label-pop 980ms ease-out both;
}

.hand .card.card-visual-weapon-return {
  animation: hand-card-weapon-zone-return var(--weapon-zone-return-ms, 360ms) cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.speed-fast {
  --weapon-zone-out-ms: 135ms;
  --weapon-zone-return-ms: 270ms;
}

.unit.unit-visual-call::after,
.unit.unit-visual-vanguard-reveal::after,
.unit.unit-visual-level-up::after,
.unit.unit-visual-position::after,
.unit.unit-visual-attack-call::after,
.unit.unit-visual-target-call::after,
.unit.unit-visual-block::after,
.unit.unit-visual-effect-source::after,
.unit.unit-visual-effect-damage::after,
.unit.unit-visual-hp-recovery::after,
.unit.unit-visual-active-change::after,
.unit.unit-zone-ghost.unit-visual-effect-break-destroyed::after,
.card.card-visual-effect-source::after,
.card.card-visual-draw::after,
.card.card-visual-cost::after,
.card.card-visual-cost-reveal::after,
.card.card-visual-effect-break::after,
.card.card-visual-weapon-return::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.unit.unit-visual-call::after {
  inset: -3px;
  border: 1px solid rgba(255, 230, 158, 0.58);
  border-radius: 9px;
  background:
    radial-gradient(ellipse at 50% 88%, rgba(255, 230, 158, 0.5), transparent 46%),
    radial-gradient(circle at 50% 44%, rgba(255, 225, 154, 0.3), transparent 55%),
    linear-gradient(0deg, rgba(89, 204, 191, 0.18), rgba(255, 225, 154, 0.15) 52%, transparent 78%);
  box-shadow:
    0 7px 16px rgba(255, 218, 121, 0.18),
    inset 0 -10px 18px rgba(105, 218, 201, 0.12);
  animation: unit-call-flash 360ms ease-out both;
}

.unit.unit-visual-vanguard-reveal::after {
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 235, 168, 0.42), transparent 56%),
    linear-gradient(135deg, rgba(255, 235, 168, 0.22), transparent 48%);
  animation: unit-vanguard-reveal-flash 980ms ease-out both;
}

.unit.unit-visual-level-up::after {
  inset: -4px;
  border: 1px solid rgba(255, 229, 143, 0.78);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 239, 178, 0.4), transparent 53%),
    linear-gradient(0deg, transparent 8%, rgba(103, 211, 194, 0.16) 36%, rgba(255, 226, 137, 0.34) 58%, transparent 82%);
  box-shadow:
    0 0 18px rgba(255, 218, 112, 0.3),
    inset 0 0 16px rgba(118, 221, 202, 0.14);
  animation: unit-level-up-flash 440ms ease-out both;
}

.unit.unit-visual-position::after {
  border: 2px solid rgba(104, 208, 200, 0.72);
  border-radius: 8px;
  box-shadow: inset 0 0 18px rgba(104, 208, 200, 0.22);
  animation: unit-position-flash 620ms ease-out both;
}

.unit.unit-visual-attack-call::after {
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 210, 104, 0.38), transparent 54%),
    linear-gradient(135deg, transparent 22%, rgba(255, 210, 104, 0.3) 46%, transparent 68%);
  animation: unit-battle-call-flash 820ms ease-out both;
}

.unit.unit-visual-target-call::after {
  border: 2px solid rgba(255, 122, 104, 0.72);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 48%, rgba(255, 122, 104, 0.16), transparent 58%);
  box-shadow:
    inset 0 0 18px rgba(255, 122, 104, 0.18),
    0 0 14px rgba(255, 122, 104, 0.14);
  animation: unit-battle-target-flash 820ms ease-out both;
}

.unit.unit-visual-block::after {
  border: 2px solid rgba(125, 188, 255, 0.76);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 48%, rgba(125, 188, 255, 0.2), transparent 58%),
    linear-gradient(145deg, rgba(125, 188, 255, 0.18), transparent 46%);
  box-shadow:
    inset 0 0 18px rgba(125, 188, 255, 0.2),
    0 0 18px rgba(125, 188, 255, 0.18);
  animation: unit-block-flash 760ms ease-out both;
}

.unit.unit-visual-call::after,
.unit.unit-visual-vanguard-reveal::after,
.unit.unit-visual-level-up::after,
.unit.unit-visual-position::after,
.unit.unit-visual-attack-call::after,
.unit.unit-visual-target-call::after,
.unit.unit-visual-block::after {
  animation-delay: var(--unit-visual-delay, 0ms);
}

.unit.unit-visual-effect-source::after,
.card.card-visual-effect-source::after {
  border: 2px solid rgba(255, 225, 154, 0.82);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 225, 154, 0.26), transparent 56%),
    linear-gradient(135deg, rgba(255, 225, 154, 0.2), transparent 50%);
  box-shadow:
    inset 0 0 20px rgba(255, 225, 154, 0.2),
    0 0 22px rgba(255, 225, 154, 0.22);
  animation: source-card-flash 920ms ease-out both;
}

.unit.unit-visual-effect-damage::after {
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 82, 66, 0.42), transparent 62%),
    linear-gradient(180deg, transparent 20%, rgba(255, 70, 58, 0.28), transparent 78%);
  box-shadow: inset 0 0 18px rgba(255, 72, 56, 0.24);
  animation: hp-damage-wash 620ms ease-out both;
}

.unit.unit-visual-hp-recovery::after {
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.52), transparent 60%),
    linear-gradient(180deg, transparent 18%, rgba(220, 255, 238, 0.32), transparent 80%);
  box-shadow:
    inset 0 0 18px rgba(240, 255, 248, 0.26),
    0 0 12px rgba(192, 255, 220, 0.22);
  animation: hp-recovery-wash 760ms ease-out both;
}

.unit.unit-visual-effect-damage::before,
.unit.unit-zone-ghost.unit-visual-effect-damage-destroyed::before {
  content: attr(data-damage-label);
  position: absolute;
  top: 34%;
  left: 50%;
  z-index: 9;
  pointer-events: none;
  color: #fff2e6;
  font-size: clamp(16px, 1.45em, 24px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    0 2px 2px rgba(45, 4, 0, 0.92),
    0 0 8px rgba(255, 76, 52, 0.92);
  animation: effect-damage-number 760ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
}

.unit.unit-visual-effect-recovery::before {
  content: attr(data-recovery-label);
  position: absolute;
  top: 34%;
  left: 50%;
  z-index: 9;
  pointer-events: none;
  color: #f3fff8;
  font-size: clamp(16px, 1.45em, 24px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    0 2px 2px rgba(5, 43, 24, 0.9),
    0 0 9px rgba(188, 255, 220, 0.92);
  animation: effect-recovery-number 820ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.unit.unit-zone-ghost.unit-visual-effect-damage-destroyed {
  pointer-events: none;
  animation: board-unit-effect-damage-destroyed var(--unit-zone-ghost-duration, 920ms) ease-out both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
  transform-origin: 50% 58%;
  will-change: opacity, transform, filter;
}

.unit.unit-zone-ghost.unit-visual-effect-damage-destroyed .hpbar-current {
  width: 0% !important;
  animation: none;
  transition: none;
}

.unit.unit-zone-ghost.unit-visual-effect-break-destroyed {
  pointer-events: none;
  transform-origin: 50% 58%;
  will-change: opacity, transform, filter;
  animation: board-unit-effect-break-destroyed var(--unit-zone-ghost-duration, 1040ms) ease-out both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
}

.unit.unit-zone-ghost.unit-visual-effect-break-destroyed::before {
  content: var(--i18n-effectDestroyed, "効果破壊");
  position: absolute;
  top: 38%;
  left: 50%;
  z-index: 10;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border: 1px solid rgba(255, 222, 172, 0.9);
  border-radius: 999px;
  background: rgba(92, 31, 24, 0.94);
  color: #fff0cf;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 14px rgba(255, 104, 72, 0.46);
  animation: effect-break-label-pop var(--unit-zone-ghost-duration, 1040ms) ease-out both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
}

.unit.unit-zone-ghost.unit-visual-effect-break-destroyed::after,
.card.card-visual-effect-break::after {
  inset: -2px;
  border: 2px solid rgba(255, 122, 87, 0.86);
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 237, 186, 0.68), transparent 24%),
    repeating-conic-gradient(from 12deg at 50% 48%, rgba(255, 114, 78, 0.32) 0 2deg, transparent 2deg 24deg);
  box-shadow:
    inset 0 0 22px rgba(255, 79, 54, 0.34),
    0 0 22px rgba(255, 99, 67, 0.42);
  animation: effect-break-flash 1040ms ease-out both;
  animation-delay: var(--unit-zone-ghost-delay, 0ms);
}

.unit.unit-visual-active-change::after {
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 48%, rgba(157, 226, 255, 0.24), transparent 58%),
    linear-gradient(135deg, rgba(157, 226, 255, 0.16), transparent 48%);
  animation: unit-active-flash 760ms ease-out both;
}

.card.card-visual-draw::after {
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 236, 174, 0.34), transparent 58%),
    linear-gradient(180deg, rgba(255, 236, 174, 0.18), transparent 48%);
  animation: card-zone-flash 760ms ease-out both;
}

.card.card-visual-cost::after {
  border: 2px solid rgba(116, 206, 160, 0.7);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(116, 206, 160, 0.16), transparent 48%);
  box-shadow:
    inset 0 0 18px rgba(116, 206, 160, 0.22),
    0 0 16px rgba(116, 206, 160, 0.18);
  animation: card-placement-flash 280ms ease-out both;
}

.card.card-visual-cost-reveal::after {
  border: 2px solid #b3e8ff;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 20%, rgba(211, 248, 255, .5) 48%, transparent 76%);
  box-shadow: inset 0 0 16px rgba(136, 222, 255, .35), 0 0 14px rgba(136, 222, 255, .4);
  animation: card-zone-flash 900ms ease-out both;
}

.card.card-visual-weapon-return::after {
  border: 2px solid rgba(255, 225, 154, 0.66);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 225, 154, 0.2), transparent 58%),
    linear-gradient(135deg, rgba(255, 225, 154, 0.14), transparent 48%);
  box-shadow:
    inset 0 0 16px rgba(255, 225, 154, 0.18),
    0 0 16px rgba(255, 225, 154, 0.16);
  animation: card-zone-flash 560ms ease-out both;
}

.card > *,
.unit > * {
  position: relative;
  z-index: 2;
}

.card-info {
  position: relative;
  z-index: 2;
}

.card.has-card-art,
.unit.has-card-art {
  background-image: none;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-end;
  box-shadow:
    var(--shadow-card-polished),
    0 0 0 1px var(--card-edge-dark),
    inset 0 1px 0 rgba(255, 246, 210, 0.18),
    inset 0 -26px 34px rgba(0, 0, 0, 0.24);
}

/* イラストだけを保持し、名前・HP・選択枠の再描画でCSS背景を作り直さない。 */
.card > .card-art-surface,
.unit > .card-art-surface,
.warrior-portrait {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.card-art-surface > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--warrior-portrait-position, center);
}

.card-art-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 15, 12, 0.02), rgba(13, 15, 12, 0.22));
  box-shadow: inset 0 1px 0 rgba(255, 246, 210, 0.18), inset 0 -26px 34px rgba(0, 0, 0, 0.24);
}

.type-weapon > .card-art-surface::after {
  background: linear-gradient(180deg, rgba(13, 15, 12, 0.02), rgba(13, 15, 12, 0.16));
}

.unit-row > .unit.has-card-art {
  box-shadow:
    var(--shadow-card-polished),
    0 11px 10px -9px rgba(0, 0, 0, 0.48),
    0 0 0 1px var(--card-edge-dark),
    inset 0 1px 0 rgba(255, 246, 210, 0.18),
    inset 0 -26px 34px rgba(0, 0, 0, 0.24);
}

.card.type-weapon,
.unit.type-weapon {
  display: flex;
  align-items: flex-end;
}

.card.type-weapon,
.unit.type-weapon,
.selection-art-card.type-weapon,
.art-modal-card.type-weapon {
  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;
}

.selection-art-card.has-card-art.type-weapon,
.art-modal-card.has-card-art.type-weapon {
  background-image:
    linear-gradient(180deg, rgba(13, 15, 12, 0.02), rgba(13, 15, 12, 0.16)),
    var(--card-art),
    linear-gradient(var(--weapon-attr-tint), var(--weapon-attr-tint)),
    var(--weapon-art-back);
}

/* 省略面では紙素材に描かれた四角い縁を外へ逃がし、角丸はカードの枠に任せる。 */
.card.type-weapon,
.unit.type-weapon,
.selection-art-card.type-weapon {
  background-size: cover, cover, 120% 120%;
}

.selection-art-card.has-card-art.type-weapon {
  background-size: cover, cover, cover, 120% 120%;
}

.card.has-card-art.type-weapon,
.unit.has-card-art.type-weapon {
  background-image:
    linear-gradient(var(--weapon-attr-tint), var(--weapon-attr-tint)),
    var(--weapon-art-back);
  background-size: cover, 120% 120%;
}

.weapon-special-fire {
  --weapon-attr-tint: rgba(231, 88, 62, 0.2);
}

.weapon-special-water {
  --weapon-attr-tint: rgba(70, 157, 226, 0.2);
}

.weapon-special-wind {
  --weapon-attr-tint: rgba(87, 199, 143, 0.18);
}

.weapon-special-thunder {
  --weapon-attr-tint: rgba(238, 205, 70, 0.22);
}

.weapon-special-ice {
  --weapon-attr-tint: rgba(125, 219, 238, 0.19);
}

.weapon-special-ground {
  --weapon-attr-tint: rgba(171, 129, 76, 0.2);
}

.weapon-special-light {
  --weapon-attr-tint: rgba(246, 233, 164, 0.22);
}

.weapon-special-dark {
  --weapon-attr-tint: rgba(91, 72, 151, 0.24);
}

.card.has-card-art .card-info,
.unit.has-card-art .card-info,
.card.type-weapon .card-info,
.unit.type-weapon .card-info {
  width: calc(100% - 8px);
  margin-left: 8px;
  margin-top: auto;
  padding: 7px 8px 8px 10px;
  border-radius: var(--info-box-radius);
  background:
    linear-gradient(180deg, rgba(21, 24, 20, 0.16), rgba(14, 16, 13, 0.8) 22%, rgba(10, 12, 10, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 -6px 16px rgba(0, 0, 0, 0.16);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.78);
}

.hand .card .card-info,
.cost .card .card-info {
  flex: 0 0 calc(100% + 10px);
  width: calc(100% + 10px);
  max-width: none;
  margin-left: -5px;
  margin-top: auto;
  padding: 7px 3px 8px 5px;
  border-radius: var(--info-box-radius);
  background:
    linear-gradient(180deg, rgba(21, 24, 20, 0.16), rgba(14, 16, 13, 0.8) 22%, rgba(10, 12, 10, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 -6px 14px rgba(0, 0, 0, 0.14);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.78);
}

.unit.has-card-art .card-info {
  width: 100%;
  margin-left: 0;
  padding: 6px 6px 7px;
  border-radius: max(1px, calc(var(--board-card-width) * var(--compact-card-corner-ratio) - var(--unit-frame-padding)));
}

.card:not(.has-card-art) .name,
.unit:not(.has-card-art) .name {
  padding-left: 0;
}

.card.type-weapon .name,
.unit.type-weapon .name {
  padding-left: 0;
}

.card {
  width: 132px;
  min-height: 188px;
  padding: 8px;
}

.card.progress-disabled-card {
  opacity: 0.78;
  filter: grayscale(0.3) brightness(0.92) saturate(0.9);
}

.card.progress-disabled-card.selected {
  opacity: 0.9;
  filter: grayscale(0.2) brightness(0.99) saturate(0.96);
}

.card.progress-disabled-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(15, 17, 15, 0.08), rgba(15, 17, 15, 0.24)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 9px);
}

.unit {
  --unit-frame-padding: clamp(1px, calc(var(--board-card-width) * 0.018), 3px);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: var(--unit-frame-padding);
  border-radius: calc(var(--board-card-width) * var(--compact-card-corner-ratio));
}

.card.selected,
.unit.selected,
.unit.targeted {
  z-index: 7;
  border-color: var(--ui-active-border);
  filter: brightness(1.07) saturate(1.05);
  transform: translateY(-2px) scale(1.012);
  box-shadow:
    0 0 0 2px rgba(255, 225, 154, 0.58),
    0 0 18px rgba(255, 225, 154, 0.38),
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -18px 26px rgba(0, 0, 0, 0.18);
  animation: card-selection-breathe 1800ms ease-in-out infinite;
}

.unit > .unit-selection-frame {
  position: absolute;
  inset: -1px;
  z-index: 3;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
}

.unit.selected > .unit-selection-frame {
  border-color: var(--ui-active-border);
  box-shadow: 0 0 8px rgba(255, 225, 154, 0.32);
}

.unit.selected > .level-badge,
.unit.selected > .rest-badge,
.unit.targeted > .level-badge,
.unit.targeted > .rest-badge {
  z-index: 4;
}

.card.tutorial-highlight,
.unit.tutorial-highlight,
.life-pile.tutorial-highlight,
.battle-attack-choice-card.tutorial-highlight,
.battle-weapon-choice-section .battle-choice-card.tutorial-highlight,
.battle-attack-actions button.tutorial-highlight,
.zone-count.cost-payable-count.tutorial-highlight,
.actions button.tutorial-highlight {
  position: relative;
  z-index: 8;
  border-color: rgba(139, 215, 229, 0.92);
  box-shadow:
    0 0 0 2px rgba(139, 215, 229, 0.44),
    0 0 20px rgba(139, 215, 229, 0.38),
    0 8px 20px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: tutorial-highlight-pulse 1500ms ease-in-out infinite;
}

/* 数字の操作位置は固定し、確認ボタンは光だけで案内する。 */
.zone-count.cost-payable-count.tutorial-highlight {
  animation-name: tutorial-cost-highlight-pulse;
}

.card-guide-frame {
  position: absolute;
  inset: -1px;
  z-index: 3;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
}

/* 案内の脈動は枠だけにかけ、カード絵の明るさと拡大率を毎周期変えない。 */
.card.tutorial-highlight,
.unit.tutorial-highlight,
.battle-attack-choice-card.tutorial-highlight,
.battle-weapon-choice-section .battle-choice-card.tutorial-highlight {
  animation: none;
}

.card.tutorial-highlight > .card-guide-frame,
.unit.tutorial-highlight > .unit-selection-frame,
.battle-attack-choice-card.tutorial-highlight > .card-guide-frame,
.battle-weapon-choice-section .battle-choice-card.tutorial-highlight > .card-guide-frame {
  border-color: rgba(185, 245, 255, 0.85);
  box-shadow: 0 0 14px rgba(139, 215, 229, 0.55);
  animation: tutorial-highlight-ring 1500ms ease-in-out infinite;
}

.hand .card.tutorial-highlight,
.cost .card.tutorial-highlight {
  z-index: 70;
  transform: translateY(-4px) scale(1.018);
}

.hand .card.tutorial-highlight {
  animation: none;
  transform:
    translateY(calc((var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)) - 6px))
    rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
    scale(1.004);
}

.hand .card.tutorial-highlight .level-badge,
.cost .card.tutorial-highlight .level-badge {
  z-index: 72;
}

.actions button.tutorial-highlight {
  filter: brightness(1.08) saturate(1.08);
}

.hand .card.selected,
.cost .card.selected {
  transform: translateY(-4px) scale(1.018);
}

.hand .card.selected {
  transform:
    translateY(calc((var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)) - 6px))
    rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
    scale(1.004);
}

.hand .card.selected:active:not(:disabled),
.hand .card.tutorial-highlight:active:not(:disabled) {
  transform:
    translateY(calc((var(--hand-card-lift, 0px) * var(--hand-card-lift-direction, 1)) - 6px))
    rotate(calc(var(--hand-card-rotate, 0deg) * var(--hand-card-rotate-direction, 1)))
    scale(1.004);
}

@supports selector(.player-panel:has(.card.selected)) {
  .player-panel:has(.tutorial-highlight),
  .player-panel:has(.tutorial-highlight) .hand-zone,
  .player-panel:has(.tutorial-highlight) .cost-zone,
  .player-panel:has(.tutorial-highlight) .hand,
  .player-panel:has(.tutorial-highlight) .cost {
    overflow: visible;
  }

  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .card:not(.selected):not(.target-candidate):not(.special-wait-candidate):not(.battle-weapon-selected):not(.battle-predesignated-target),
  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .unit:not(.selected):not(.targeted):not(.target-candidate):not(.battle-predesignated-target) {
    filter: brightness(0.92) saturate(0.95);
  }

  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .card.selected,
  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .unit.selected,
  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .unit.targeted,
  .app:not(.mobile-safari-layout):not(.mobile-fullscreen-layout) .player-panel:has(.card.selected, .unit.selected, .unit.targeted) .battle-predesignated-target {
    filter: brightness(1.08) saturate(1.06);
  }
}

@supports selector(.lane:has(.unit.selected)) {
  .player-panel:has(.unit.selected, .unit.targeted) {
    overflow: visible;
    z-index: 64;
  }

  .lane:has(.unit.selected, .unit.targeted),
  .lane:has(.unit.selected, .unit.targeted) .unit-row {
    overflow: visible;
    z-index: 66;
  }

  .unit-row .unit.selected,
  .unit-row .unit.targeted {
    z-index: 68;
  }

  .unit-row .unit.selected .level-badge,
  .unit-row .unit.targeted .level-badge {
    z-index: 70;
  }
}

.unit.unit-position-cancelable {
  border-color: rgba(125, 188, 255, 0.96);
  box-shadow:
    0 0 0 2px rgba(125, 188, 255, 0.34),
    0 0 16px rgba(125, 188, 255, 0.2);
}

.unit.unit-position-cancelable::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 45%, rgba(125, 188, 255, 0.18), transparent 58%),
    linear-gradient(135deg, rgba(125, 188, 255, 0.13), transparent 52%);
  animation: position-change-cancelable-pulse 1800ms ease-in-out infinite;
}

.card.stacked {
  border-color: var(--special);
  filter: brightness(1.04) saturate(1.08);
  box-shadow:
    0 0 0 2px rgba(170, 156, 255, 0.5),
    0 0 18px rgba(170, 156, 255, 0.28);
}

.card.special-wait-candidate {
  border-color: #85e6a6;
  box-shadow:
    0 0 0 2px rgba(116, 232, 158, 0.62),
    0 0 20px rgba(116, 232, 158, 0.42),
    0 0 34px rgba(244, 211, 94, 0.18);
}

.card.special-wait-candidate > .card-guide-frame {
  border-color: #85e6a6;
  animation: special-wait-card-pulse 1250ms ease-in-out infinite;
}

.unit.targeted {
  border-color: var(--danger);
  filter: brightness(1.02) saturate(1.08);
  box-shadow:
    0 0 0 2px rgba(220, 107, 87, 0.5),
    0 0 18px rgba(220, 107, 87, 0.26);
}

.unit.targeted > .unit-selection-frame {
  border-color: var(--danger);
  box-shadow: 0 0 8px rgba(220, 107, 87, 0.3);
}

.unit.target-candidate,
.card.target-candidate {
  border-color: #b9e7ff;
  filter: brightness(1.06) saturate(1.05);
  box-shadow:
    0 0 0 2px rgba(159, 220, 255, 0.52),
    0 0 16px rgba(159, 220, 255, 0.3),
    0 0 28px rgba(255, 225, 154, 0.12);
  animation: target-candidate-breathe 1500ms ease-in-out infinite;
}

.player-panel.target-choice-active .unit:not(.target-candidate):not(.selected):not(.targeted) {
  opacity: 1;
  filter: brightness(0.82) saturate(0.88);
}

.target-mode {
  color: #ffe6a4;
  font-weight: 800;
}

.status-warning-line {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 6px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid rgba(244, 199, 95, 0.62);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(122, 78, 23, 0.44), rgba(24, 22, 18, 0.88) 64%),
    rgba(18, 19, 16, 0.94);
  color: #fff0bd;
  font-size: 12px;
  line-height: 1.25;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.28),
    0 0 14px rgba(244, 199, 95, 0.12);
}

.status-warning-line:has(.rule-context-link) {
  gap: 2px;
  padding-right: 1px;
}

.status-warning-message {
  min-width: 0;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.status-warning-line .rule-context-link {
  flex: 0 0 auto;
  width: 30px;
  min-width: 30px;
  min-height: 28px;
  padding: 2px;
  font-size: 10px;
}

.status-warning-icon {
  flex: 0 0 auto;
  color: #ffd66b;
  text-shadow: 0 0 8px rgba(244, 199, 95, 0.42);
}

.name {
  min-height: 38px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.unit .name {
  min-height: 30px;
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.stat-line,
.tag-line,
.effect-line {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.25;
}

.type-label {
  display: inline-block;
  margin-bottom: 1px;
  font-weight: 900;
  letter-spacing: 0;
}

.type-warrior .type-label {
  color: #ff9b92;
}

.awakened-warrior-card .type-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 1px 5px;
  border: 1px solid rgba(255, 155, 146, 0.68);
  border-radius: 4px;
  color: #ffb2aa;
  background: rgba(97, 36, 36, 0.78);
  box-shadow: 0 0 0 1px rgba(77, 28, 18, 0.25);
}

.type-weapon .type-label {
  color: #8ab8ff;
}

.type-special .type-label {
  color: #88e49b;
}

.unit-stat-line {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.15;
}

/* 多属性は省略を示し、全属性は戦士を選択した詳細で確認する。 */
.app:not(.mobile-landscape-layout) .unit-attribute-line {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* 英語の4属性を収め、アイコンと数値・補正を途中で分割しない。 */
.unit-attribute-line:lang(en) {
  word-spacing: -0.12em;
}

.unit-attribute-line:lang(en) .unit-attribute-item {
  display: inline-block;
  white-space: nowrap;
}

.unit-attribute-line:lang(en) .weapon-attribute-icon {
  margin-right: 0.04em;
}

.unit-attribute-line:lang(en) .weapon-attribute-icon::before {
  width: 1.15em;
  height: 1.15em;
}

.unit-health-row {
  display: contents;
}

.unit-stack-count {
  white-space: nowrap;
}

.stat-line {
  color: #f2ead4;
  font-weight: 750;
}

.tag-line {
  min-height: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.tag-line:empty {
  display: none;
}

.effect-line {
  display: -webkit-box;
  max-height: 76px;
  overflow: hidden;
  color: #dcd6c4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.effect-line:empty {
  display: none;
}

.boosted-stat {
  color: #73e0a5;
  font-weight: 800;
}

.attr-stat {
  display: inline-block;
  text-shadow: 0 0 8px rgba(115, 224, 165, 0.22);
}

.debuffed-stat {
  color: #ff9a83;
  font-weight: 800;
}

.stat-delta {
  margin-left: 3px;
  color: #a6eec3;
  font-size: 11px;
  font-weight: 700;
}

.debuff-delta {
  color: #ffb19f;
}

.hpbar {
  position: relative;
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: #151714;
  overflow: hidden;
}

.hpbar > span {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms ease, background 180ms ease;
}

.hpbar > .hpbar-current {
  z-index: 2;
}

.hpbar > .hpbar-trail {
  z-index: 1;
  background: linear-gradient(90deg, rgba(255, 94, 75, 0.9), rgba(255, 185, 88, 0.82));
  box-shadow: 0 0 10px rgba(255, 114, 82, 0.35);
  transition: none;
  animation: hpbar-trail-decrease 820ms cubic-bezier(0.2, 0.74, 0.18, 1) both;
}

.hp-full > span {
  background: linear-gradient(90deg, #4fbf70, #86d86c);
}

.hp-wounded > span {
  background: linear-gradient(90deg, #d9b94d, #f0d46a);
}

.hp-danger > span {
  background: linear-gradient(90deg, #d84f43, #f0805c);
}

.rested {
  filter: saturate(0.62);
}

.level-badge {
  position: absolute;
  top: -7px;
  left: -7px;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 238, 179, 0.9);
  border-radius: 50%;
  background: rgba(27, 30, 26, 0.92);
  color: #ffe19a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.hand .level-badge,
.cost .level-badge {
  top: -4px;
  left: -4px;
  width: 19px;
  height: 19px;
  font-size: 10px;
}

.rest-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  padding: 2px 5px;
  border: 1px solid rgba(255, 196, 149, 0.82);
  border-radius: 0 5px 0 5px;
  background: rgba(92, 36, 25, 0.9);
  color: #ffd8bd;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.unit-role-badges {
  position: absolute;
  top: -10px;
  right: -8px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  pointer-events: none;
}

.attack-role-badge {
  display: inline-grid;
  place-items: center;
  padding: 3px 8px 4px;
  min-width: 40px;
  border: 1px solid rgba(255, 233, 166, 0.86);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(82, 63, 30, 0.98), rgba(43, 46, 54, 0.98));
  color: #fff0bc;
  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.78);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.36);
}

.unit.commander,
.unit.commander.selected {
  z-index: 18;
  overflow: visible;
  border-color: #e45b4a;
  box-shadow:
    0 0 0 2px rgba(220, 72, 58, 0.36),
    0 0 20px rgba(220, 72, 58, 0.2);
}

.unit.commander.targeted {
  border-color: var(--danger);
  box-shadow:
    0 0 0 2px rgba(220, 107, 87, 0.42),
    0 0 20px rgba(220, 72, 58, 0.22);
}

.unit.unit-special-event-commander {
  z-index: 28;
  overflow: visible;
  animation: special-event-commander-unit var(--special-event-duration, 1320ms) ease-in-out both;
  animation-delay: var(--special-event-delay, 0ms);
}

.special-commander-focus {
  position: absolute !important;
  inset: -7px !important;
  z-index: 26 !important;
  border: 2px solid rgba(255, 226, 151, 0.9);
  border-radius: 11px;
  box-shadow:
    0 0 0 1px rgba(255, 248, 211, 0.18),
    0 0 18px rgba(255, 222, 133, 0.72),
    0 0 38px rgba(224, 91, 70, 0.42),
    inset 0 0 18px rgba(255, 233, 170, 0.2);
  opacity: 0;
  pointer-events: none;
  animation: special-event-commander-ring var(--special-event-duration, 1320ms) ease-in-out both;
  animation-delay: var(--special-event-delay, 0ms);
}

.unit.unit-special-event-awaken {
  z-index: 28;
  overflow: visible;
  isolation: isolate;
  animation: special-event-awaken-unit var(--special-event-duration, 1800ms) ease-out both;
  animation-delay: var(--special-event-delay, 0ms);
}

.special-awaken-focus {
  position: absolute !important;
  inset: -4px !important;
  z-index: 42 !important;
  overflow: visible;
  border: 1px solid rgba(241, 211, 113, 0.82);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 48%, rgba(111, 84, 30, 0.32), transparent 52%),
    linear-gradient(155deg, rgba(11, 13, 18, 0.94), rgba(25, 20, 13, 0.97));
  box-shadow:
    0 0 0 1px rgba(255, 246, 207, 0.14),
    0 0 18px rgba(224, 184, 78, 0.38),
    inset 0 0 24px rgba(244, 209, 105, 0.12);
  pointer-events: none;
  animation: special-event-awaken-seal var(--special-event-duration, 1800ms) ease-out both;
  animation-delay: var(--special-event-delay, 0ms);
}

.special-awaken-focus::before,
.special-awaken-focus::after {
  content: "";
  position: absolute;
  pointer-events: none;
  animation-delay: var(--special-event-delay, 0ms);
}

.special-awaken-focus::before {
  inset: -30%;
  background: url("../assets/effects/unit/awakening_seal.webp") center / contain no-repeat;
  filter:
    brightness(1.08)
    drop-shadow(0 0 7px rgba(255, 229, 145, 0.82))
    drop-shadow(0 0 18px rgba(229, 177, 62, 0.42));
  animation: special-event-awaken-emblem var(--special-event-duration, 1800ms) cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

.special-awaken-focus::after {
  inset: -30%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 9%, rgba(255, 240, 177, 0.94) 18%, rgba(247, 202, 91, 0.34) 42%, transparent 68%);
  mix-blend-mode: screen;
  animation: special-event-awaken-flash var(--special-event-duration, 1800ms) ease-out both;
}

.commander-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  z-index: 24;
  transform: translateX(-50%);
  padding: 2px 10px 3px;
  border: 1px solid rgba(255, 214, 185, 0.82);
  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;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.face-down {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 86px;
  color: #f2efe4;
  background:
    linear-gradient(180deg, rgba(14, 17, 14, 0.05), rgba(14, 17, 14, 0.32)),
    var(--card-back);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.face-down-label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border: 1px solid rgba(255, 238, 194, 0.42);
  border-radius: 999px;
  background: rgba(13, 16, 13, 0.68);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.34);
  color: #f7ecd0;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.hidden-hand-card {
  min-height: var(--compact-card-height);
  text-align: center;
  color: var(--muted);
}

.hidden-hand-card:disabled {
  cursor: default;
  opacity: 1;
}
