/* 対戦（試作版）の画面: ロビー・デッキ編成・対戦。
   サイト本体（style.css）の色と部品をそのまま使う。色を足すのは、ライフ（赤）と増減の数字だけ。 */

/* ---------- トップページの入口 ---------- */
.hero__battle {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}
.hero__battle .btn svg {
  width: 19px;
  height: 19px;
}

/* ---------- 全体 ---------- */
.battle {
  --hurt: #d92d3c;
  --good: #16935a;
  position: fixed;
  inset: 0;
  z-index: 30; /* ヘッダー(20) より上、図鑑などのシート(40)・カード詳細(50)・確認(70) より下 */
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: stage-in 0.2s ease-out both;
}
.bt {
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 24px) calc(28px + env(safe-area-inset-bottom));
}
.bt__head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 0 10px;
  background: var(--bg);
}
.bt__head h2 {
  flex: 1;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.3;
}
.bt__head h2 small {
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  vertical-align: 2px;
}
.bt__record {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.bt__lead {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.bt .box h3 {
  margin-bottom: 10px;
}
.bt .seg {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 12px;
}

/* ---------- ロビー ---------- */
.bt-decks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}
.bt-deck {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  transition: box-shadow 0.15s;
}
.bt-deck.is-on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.bt-deck.is-bad {
  border-style: dashed;
}
.bt-deck__main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  background: none;
  text-align: left;
}
.bt-deck__thumbs {
  flex: none;
  display: flex;
  width: 96px;
}
.bt-deck__thumbs .thumb {
  flex: none;
  width: 48px;
  border-radius: 6px;
  box-shadow: 0 0 0 2px var(--panel);
}
.bt-deck__thumbs .thumb + .thumb {
  margin-left: -24px;
}
.bt-deck__text {
  display: grid;
  min-width: 0;
  line-height: 1.45;
}
.bt-deck__text b {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bt-deck__text i {
  margin-left: 6px;
  font-size: 10.5px;
  font-style: normal;
  letter-spacing: 0.05em;
  color: #e8a013;
}
.bt-deck__text small {
  display: -webkit-box;
  overflow: hidden;
  font-size: 11.5px;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.bt-deck.is-bad .bt-deck__text small {
  color: var(--hurt);
}
.bt-deck > .btn {
  flex: none;
  margin-right: 9px;
}
.bt-deck--new {
  flex-direction: column;
  justify-content: center;
  min-height: 62px;
  padding: 8px 12px;
  border-style: dashed;
  background: transparent;
  line-height: 1.5;
}
.bt-deck--new b {
  font-size: 13.5px;
  font-weight: 800;
}
.bt-deck--new small {
  font-size: 11.5px;
  color: var(--muted);
}
.bt-deck--new:hover {
  background: var(--panel);
}
.bt-level {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
.bt .bt-level .seg {
  margin: 0;
}
.bt-code__area {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-all;
  resize: vertical;
}
.bt-code__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 8px 0 10px;
}
.bt-code__error {
  flex: 1;
  min-width: 180px;
  font-size: 12.5px;
  color: var(--hurt);
}
/* 「対戦をはじめる」は、長いロビーのどこにいても押せるように下に固定する */
.bt__start {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 0 calc(clamp(12px, 3vw, 24px) * -1);
  padding: 14px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.bt__start .btn {
  width: min(100%, 320px);
}
.bt__start p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.bt-share {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.bt-rules summary {
  font-size: 14.5px;
  font-weight: 900;
  cursor: pointer;
}
.bt-rules ul {
  margin: 8px 0 0;
  padding-left: 1.3em;
  font-size: 13px;
  color: var(--muted);
}
.bt-rules li {
  margin: 3px 0;
}
.bt-rules b {
  color: var(--ink);
  font-weight: 800;
}
.bt-rules h4 {
  margin: 16px 0 0;
  font-size: 13.5px;
  font-weight: 900;
  color: var(--ink);
}
.bt-rules__traits {
  padding-left: 0 !important;
  list-style: none;
}
.bt-rules__traits li {
  margin: 8px 0 0;
}
.bt-rules__traits li > b {
  display: block;
}
.bt-rules__traits span {
  display: block;
  padding-left: 0.2em;
}
.bt-rules__traits i {
  margin-right: 0.5em;
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
}
/* 対戦中に「？」から開いたとき（確認の小窓の中） */
.modal__body .bt-rules {
  max-height: min(60vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
}
.modal__body .bt-rules summary {
  display: none;
}
.modal__body .bt-rules b {
  font-family: inherit;
}

/* ---------- 小さなカード（手札・編成の一覧） ---------- */
.bc {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--c);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
  text-align: center;
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s,
    opacity 0.15s;
}
.bc:active {
  transform: scale(0.96);
}
.bc.is-off {
  opacity: 0.5;
}
.bc.is-on {
  border-color: var(--ink);
  border-bottom-color: var(--c);
  box-shadow: 0 0 0 1.5px var(--ink);
}
.bc__art {
  display: block;
}
.bc__cost,
.bc__extra,
.bc__count {
  position: absolute;
  top: 3px;
  display: grid;
  place-items: center;
  height: 19px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
}
.bc__cost {
  left: 3px;
  width: 19px;
  background: var(--ink);
  color: #fff;
}
.bc__extra {
  left: 25px;
  width: 19px;
  background: #f5c341;
  color: #3d2c00;
  font-size: 11px;
}
.bc__count {
  right: 3px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.bc__name {
  overflow: hidden;
  padding: 3px 3px 0;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bc__stats,
.unit__stats {
  display: flex;
  justify-content: space-between;
  padding: 0 6px 3px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
}
.bc__stats b,
.unit__stats b {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 800;
}
.bc__stats svg,
.unit__stats svg {
  width: 11px;
  height: 11px;
  flex: none;
  color: var(--faint);
}
.bc__hp svg,
.unit__hp svg {
  color: var(--hurt);
}

/* ---------- デッキ編成 ---------- */
.bt--edit,
.bt--duel {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.bt--edit .bt__body {
  flex: 1;
  padding-bottom: 20px;
}
.bt-edit__name {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
}
.bt-edit__count {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}
.bt-edit__count.is-ok {
  color: var(--good);
}
.bt-edit__short {
  margin: 4px 0 0;
  padding: 10px 13px;
  border: 1px solid #f0dca0;
  border-radius: 12px;
  background: #fff8e2;
  font-size: 12.5px;
  color: #5c4500;
}
.bt .bt-edit__deck {
  margin-top: 12px;
  padding: 12px 14px 10px;
}
.bt-edit__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.bt .bt-edit__bar h3 {
  margin: 0;
  font-size: 14px;
}
.bt-edit__btns {
  display: flex;
  gap: 4px;
}
/* コストごとの枚数の棒グラフ */
.bt-curve {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 58px;
  margin: 10px 0 8px;
}
.bt-curve span {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  max-width: 44px;
}
.bt-curve b {
  grid-row: 1;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--muted);
}
.bt-curve i {
  grid-row: 2;
  align-self: end;
  width: 100%;
  height: var(--h);
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--ink);
}
.bt-curve small {
  grid-row: 3;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--faint);
}
.bt-edit__picked {
  display: flex;
  gap: 6px;
  padding: 2px 1px 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.bt-edit__picked .bc {
  flex: none;
  width: 70px;
}
.bt-edit__picked .box__lead {
  margin: 4px 0;
}
/* 一覧の絞り込み: 名前でさがす欄と、開け閉めできる条件の欄 */
.bt-find {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}
.bt-find__input {
  height: 40px;
  border-radius: 999px;
  background: var(--panel);
}
.bt-find__toggle {
  flex: none;
  gap: 6px;
  height: 40px;
}
.bt-find__toggle[aria-expanded="true"] {
  border-color: var(--ink);
}
/* 効いている条件の数 */
.bt-find__toggle b {
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
}
.bt .bt-filters {
  margin-top: 8px;
  padding: 4px 14px 10px;
}
.bt-filters__row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.bt-filters__row--wide {
  grid-template-columns: minmax(0, 1fr);
}
.bt-filters__label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.bt-filters__label small {
  margin-left: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
}
.bt-filters .select {
  display: flex;
  min-width: 0;
}
.bt-filters .select select {
  width: 100%;
  min-width: 0;
  max-width: 260px;
}
.bt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
/* 押すと選べるボタン（選んでいるものは、黒く塗る） */
.bt-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 36px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  transition:
    transform 0.15s var(--ease),
    background 0.15s,
    color 0.15s;
}
.bt-chip:active {
  transform: scale(0.95);
}
.bt-chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.bt-chip--num {
  width: 36px;
  padding: 0;
  font-family: var(--mono);
}
.bt-chip--tier::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}
.bt-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
}
.bt-range .select {
  flex: 1;
  max-width: 128px;
}
.bt-range select {
  padding: 0 6px 0 10px;
}
/* 効果: 系統（行）× 性格（列）の表。見出しを押すと、その行・列をまとめて選ぶ */
.bt-traits {
  display: grid;
  grid-template-columns: auto repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.bt-traits .bt-chip {
  min-width: 0;
  padding: 0 2px;
  border-radius: 9px;
  overflow: hidden;
  font-size: clamp(10px, 3vw, 12px);
}
.bt-traits .bt-chip--head {
  padding: 0 8px;
  border-color: transparent;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--muted);
}
.bt-traits .bt-chip--head[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}
/* 行・列の一部だけを選んでいる */
.bt-traits .bt-chip--head[aria-pressed="mixed"] {
  box-shadow: inset 0 0 0 1.5px var(--ink);
  color: var(--ink);
}
.bt-filters__foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
}
/* 当てはまった数と、並び順 */
.bt-listbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  margin: 12px 0 8px;
}
.bt-listbar select {
  padding: 0 8px 0 10px;
  font-size: 12.5px;
}
.bt-hits {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
/* いまの条件（「東方・コスト 2〜4」のように出す） */
.bt-conds {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.bt-conds .link,
.bt-list__note .link {
  margin-left: 8px;
  color: var(--ink);
  font-weight: 700;
}
.bt-list__note .box__lead {
  margin: 6px 0 0;
}
.bt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

/* ---------- カードの説明（画面の下の帯） ---------- */
.bt-info {
  position: sticky;
  bottom: 0;
  z-index: 4;
  min-height: 92px;
  margin: 0 calc(clamp(12px, 3vw, 24px) * -1);
  padding: 10px clamp(12px, 3vw, 24px) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  font-size: 12.5px;
  line-height: 1.6;
}
.bt-info p {
  margin: 0;
}
.bt-info__hint {
  color: var(--muted);
}
.bt-info__recap b {
  margin-right: 0.6em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.bt-info__recap + .bt-info__hint {
  margin-top: 3px;
  font-size: 12px;
}
.bt-info__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bt-info__head strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bt-info__head .link {
  flex: none;
  color: var(--muted);
}
.bt-info__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.bt-info__text b {
  margin-right: 0.3em;
  font-weight: 800;
}
.bt-info__text.is-muted {
  color: var(--faint);
  text-decoration: line-through;
}
.bt-info__status {
  font-weight: 700;
  color: #a35a00;
}

/* ---------- 対戦 ---------- */
.bt--duel {
  /* レーン1つの高さ。画面の高さに合わせて縮める（幅より高くはしない） */
  --slot-h: clamp(80px, calc((100dvh - 480px) / 2), 176px);
}
.bt--duel .bt__head {
  gap: 8px;
  padding-bottom: 8px;
}
.bt-duel__turn {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}
.bt-fast[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.bt-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 6px;
  padding-bottom: 8px;
}
.bt-side {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.bt-side__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  text-overflow: ellipsis;
}
.bt-side b {
  font-family: var(--mono);
  color: var(--ink);
}
.bt-life {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.bt-life svg {
  width: 15px;
  height: 15px;
  color: var(--hurt);
}
.bt-life__n {
  min-width: 1.3em;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}
.bt-life.is-low .bt-life__n {
  color: var(--hurt);
}
.bt-life.is-low svg {
  animation: bt-beat 0.9s ease-in-out infinite;
}
.bt-energy {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.bt-energy svg {
  width: 13px;
  height: 13px;
  color: var(--ink);
}
.bt-energy > b {
  min-width: 0.7em;
  font-size: 13.5px;
}
.bt-pips {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
}
.bt-pips i {
  width: 5px;
  height: 11px;
  border-radius: 2px;
  background: var(--line);
}
.bt-pips i.is-on {
  background: var(--ink);
}
.bt-board {
  display: grid;
  gap: 2px;
  width: min(100%, 540px);
  margin: 0 auto;
}
.bt-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bt-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 26px;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.bt-banner::before,
.bt-banner::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.bt-banner[data-side="foe"] {
  color: var(--muted);
}
.bt-slot {
  position: relative;
  aspect-ratio: 1 / 1.12;
  max-height: var(--slot-h);
}
.bt-slot__empty {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: transparent;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.bt-slot__hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.6;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.bt-slot__hint:empty {
  display: none;
}
.bt-slot.is-target .bt-slot__empty {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  animation: bt-target 1.1s ease-in-out infinite;
}
.bt-slot.is-target .unit {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink);
}
.bt-slot.is-armed .unit {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--hurt);
}
.bt-slot.is-armed .bt-slot__hint {
  background: var(--hurt);
}

/* 場に出ているカード */
.unit {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 2px solid var(--c);
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 2px 8px rgba(20, 24, 40, 0.08);
}
.unit.is-leaving {
  z-index: 2;
  pointer-events: none;
}
.unit__art {
  position: relative;
  flex: 1;
  display: block;
  min-height: 0;
  overflow: hidden;
  border-radius: 9px 9px 0 0;
}
.unit__art .thumb {
  height: 100%;
  aspect-ratio: auto;
}
.unit__marks {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  display: flex;
  gap: 3px;
}
.unit__shield,
.unit__zz {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  height: 17px;
  padding: 0 6px 0 4px;
  border-radius: 999px;
  background: rgba(17, 18, 20, 0.82);
  color: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
}
.unit__shield svg {
  width: 10px;
  height: 10px;
}
.unit__zz {
  padding: 0 6px;
  font-family: var(--font);
  background: rgba(45, 110, 220, 0.92);
}
.unit__name {
  overflow: hidden;
  padding: 2px 3px 0;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.45;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.unit .unit__stats {
  font-size: 14.5px;
  font-weight: 900;
  line-height: 1.3;
  padding: 0 7px 3px;
}
.unit__atk.is-up span {
  color: var(--good);
}
.unit__atk.is-down span {
  color: var(--c-SR);
}
.unit__hp.is-hurt span {
  color: var(--hurt);
}
.unit.is-frozen .unit__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(120, 170, 255, 0.42);
}
.unit.is-mute .unit__name {
  color: var(--faint);
  text-decoration: line-through;
}
/* カードの上に出る短い文字（能力の名前など） */
.unit__label {
  position: absolute;
  left: 50%;
  top: 30%;
  z-index: 4;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.6;
  white-space: nowrap;
  transform: translate(-50%, 0);
  pointer-events: none;
}
/* 浮かび上がる数字（ダメージ・回復） */
.bt-float {
  position: absolute;
  left: 50%;
  top: 34%;
  z-index: 5;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff,
    0 0 6px #fff;
  transform: translate(-50%, 0);
  pointer-events: none;
}
.bt-life .bt-float {
  top: -4px;
  font-size: 18px;
}
.bt-float--hit {
  color: var(--hurt);
}
.bt-float--heal {
  color: var(--good);
}

/* 手札 */
.bt-hand {
  display: flex;
  justify-content: safe center;
  gap: 6px;
  min-height: 98px;
  padding: 6px 2px 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.bt-hand::-webkit-scrollbar {
  display: none;
}
.bt-hand .bc {
  flex: 1 0 66px;
  max-width: 86px;
  align-self: flex-start;
}
.bt-hand .bc.is-on {
  transform: translateY(-4px);
}
.bt-hand__empty {
  align-self: center;
  margin: 0 auto;
  font-size: 12.5px;
  color: var(--faint);
}
.bt-actions {
  display: flex;
  justify-content: center;
}
.bt-end {
  width: min(100%, 300px);
}
.bt-end.is-nudge {
  animation: bt-nudge 1.4s ease-in-out infinite;
}

/* 結果 */
.bt-result {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 18, 26, 0.5);
  animation: stage-in 0.2s ease-out both;
}
.bt-result__panel {
  width: min(100%, 400px);
  padding: 24px 20px 18px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.bt-result__panel h3 {
  margin: 0 0 4px;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.04em;
}
.bt-result__panel.is-loss h3,
.bt-result__panel.is-draw h3 {
  color: var(--muted);
}
.bt-result__panel p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.bt-result__record {
  margin-top: 6px !important;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink) !important;
}
.bt-result__btns {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- オンライン対戦（試験版） ---------- */
.bt-net__pass {
  display: block;
  width: min(100%, 340px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 16px; /* 16px より小さいと、iPhone で入力するときに画面が拡大される */
  line-height: 1.5;
}
.bt-net__hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.bt-net__state {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-size: 13.5px;
  font-weight: 700;
}
.bt-net__state b {
  font-family: var(--mono);
  font-size: 16px;
}
.bt-net__state .link {
  color: var(--ink);
  font-size: inherit;
}
.bt-net__record {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
.bt-net__notes {
  margin: 12px 0 0;
  padding-left: 1.3em;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

/* 相手を待つ画面 */
.bt-wait {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-top: 10vh;
  padding: 30px 18px 22px;
  text-align: center;
}
.bt .bt-wait h3 {
  margin: 10px 0 0;
  font-size: 18px;
}
.bt-wait__spin {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: bt-spin 0.9s linear infinite;
}
.bt-wait__time,
.bt-wait__pass {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.bt-wait__clock {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.bt-wait__pass b {
  color: var(--ink);
  word-break: break-all;
}
.bt-wait__note {
  max-width: 34em;
  margin: 4px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

/* 対戦中: ターンの残り時間と、通信についての知らせ */
.bt-duel__clock {
  flex: none;
  min-width: 3.6em;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--muted);
}
.bt-duel__clock.is-mine {
  border-color: var(--ink);
  color: var(--ink);
}
.bt-duel__clock.is-low {
  border-color: var(--hurt);
  background: var(--hurt);
  color: #fff;
}
/* 幅の狭い画面では、残り時間が出ているあいだ「はやい」の文字をたたむ。
   ターン数が 2 行に折れないようにするため（文字は読み上げ用に残してある） */
@media (max-width: 430px) {
  .bt-duel__clock:not([hidden]) ~ .bt-fast {
    padding: 0 11px;
  }
  .bt-duel__clock:not([hidden]) ~ .bt-fast span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.bt-notice {
  margin: 0 0 6px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--hurt) 40%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--hurt) 7%, var(--panel));
  font-size: 12.5px;
  font-weight: 700;
}
.bt-notice b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.bt-result__gain {
  margin-top: 10px !important;
  color: var(--ink) !important;
}
.bt-result__gain b {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 900;
}
.bt-result__gain .badge {
  vertical-align: 1px;
}
/* レート対戦: レートがどう動いたか */
.bt-result__rate {
  margin-top: 8px !important;
  font-weight: 700;
  color: var(--ink) !important;
}
.bt-result__rate b {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 900;
}
.bt-result__rate.is-up b {
  color: var(--good);
}
.bt-result__rate.is-down b {
  color: var(--hurt);
}
.bt-result__foe {
  margin-top: 6px !important;
}
.bt-result .link {
  font-size: inherit;
}

/* ---------- 対戦の演出（光・火花・紙吹雪）を描く場所 ---------- */
/* 画面いっぱいに重ねる。押すことはできない（下の盤面をそのまま操作できる）。結果の窓（10）よりは下 */
.bt-fx,
.bt-flash {
  position: fixed;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.bt-flash {
  opacity: 0;
}

/* ---------- どんな対戦か（イベント・レート対戦）の札 ---------- */
.bt-duel__kind {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
/* 幅の狭い画面では出さない（相手の名前に、イベント・レートのことが出ている） */
@media (max-width: 520px) {
  .bt-duel__kind {
    display: none;
  }
}

/* ---------- イベント（ロビーのタブ） ---------- */
.bt-event {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px 10px 10px;
  border: 1px solid color-mix(in srgb, var(--c-EVE) 55%, var(--line));
  border-radius: 14px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--c-EVE) 12%, var(--panel)), var(--panel) 64%);
}
.bt-event__thumb {
  flex: none;
  width: 104px;
}
.bt-event__thumb .thumb {
  border-radius: 10px;
}
.bt-event__text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  line-height: 1.45;
}
.bt-event__text small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--muted);
}
.bt-event__text b {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.bt-event__text span {
  font-size: 11.5px;
  color: var(--muted);
}
.bt-event .btn {
  flex: none;
}
.bt-event + .bt-deck {
  margin-top: 10px;
}

/* ---------- レート（オンラインのタブ）と、デッキの決まり ---------- */
.bt-rate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
}
.bt-rate > span {
  white-space: nowrap;
}
.bt-rate b {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 900;
}
.bt-rate__links {
  display: inline-flex;
  gap: 12px;
  margin-left: auto;
  padding-left: 8px;
}
.bt-rate__links .link {
  color: var(--ink);
  font-size: 12.5px;
}
.bt-edit__rule {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.bt-edit__rule b {
  font-family: var(--mono);
  font-weight: 800;
  color: var(--ink);
}
.bt-edit__rule .is-over,
.bt-edit__rule .is-over b {
  color: var(--hurt);
}
.bt-edit__rule.is-bad {
  color: #5c4500;
}

@keyframes bt-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes bt-beat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
  }
}
@keyframes bt-target {
  0%,
  100% {
    background: color-mix(in srgb, var(--ink) 3%, transparent);
  }
  50% {
    background: color-mix(in srgb, var(--ink) 10%, transparent);
  }
}
@keyframes bt-nudge {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ink) 30%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--ink) 0%, transparent);
  }
}

/* ---------- 画面幅ごとの調整 ---------- */
@media (max-width: 720px) {
  .bt-decks {
    grid-template-columns: 1fr;
  }
  .bt-side {
    gap: 8px;
    padding: 5px 10px;
  }
  .bt-row {
    gap: 6px;
  }
}
/* 幅の狭い画面では、絞り込みの名前を上に置いて、選ぶところを幅いっぱいに使う（レアリティとコストが 1 行に収まる） */
@media (max-width: 480px) {
  .bt-filters__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }
  .bt-filters .select select,
  .bt-range .select {
    max-width: none;
  }
  /* レアリティとコストは、同じ幅に分けて 1 行に並べる */
  .bt-chips--fit {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
  .bt-chips--fit .bt-chip {
    width: auto;
    min-width: 0;
    padding: 0 4px;
  }
}
@media (max-width: 400px) {
  .bt-count:last-child {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .battle,
  .bt-result,
  .bt-wait__spin,
  .bt-life.is-low svg,
  .bt-slot.is-target .bt-slot__empty,
  .bt-end.is-nudge {
    animation: none;
  }
}
