/* =========================================================================
   マーケット画面
   ========================================================================= */

.market-screen {
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------- HUD */

.hud {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: max(6px, env(safe-area-inset-top)) max(10px, calc((100% - var(--col)) / 2 + 10px)) 6px;
  background: linear-gradient(180deg, rgba(10, 12, 17, 0.96), rgba(18, 21, 29, 0.9));
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.4);
}

.market-screen.intro .hud {
  animation: hud-in 0.45s var(--spring) both;
}

.market-screen.intro .market-main {
  animation: enter-up 0.45s var(--spring) 0.1s both;
}

.hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--player), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: hud-scan 4s linear infinite;
}

@keyframes hud-scan {
  from {
    background-position: -50% 0;
  }
  to {
    background-position: 150% 0;
  }
}

@keyframes hud-in {
  from {
    transform: translateY(-100%);
  }
}

.hud > * {
  flex: none;
}

.hud-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #3b4152, #151821);
  box-shadow: 0 0 0 2px var(--player), 0 0 10px color-mix(in srgb, var(--player) 60%, transparent);
  border-radius: 50%;
  overflow: hidden;
}

.hud-avatar img {
  position: absolute;
  left: 50%;
  top: 1px;
  transform: translateX(-50%);
  width: 42px;
  height: 82px;
  object-fit: cover;
  object-position: top;
}

.hud-avatar.mai img {
  top: 0;
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.hud-avatar.talking {
  animation: talk-bounce 0.3s ease-in-out infinite alternate;
}

@keyframes talk-bounce {
  to {
    transform: translateY(-2px) scale(1.04);
  }
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.stat small {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.stat b {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 19px;
}

.stat.lives b {
  color: #ff8a98;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stat.lives b::before {
  content: "";
  width: 11px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(50% 100%, 0 38%, 12% 6%, 34% 0, 50% 16%, 66% 0, 88% 6%, 100% 38%);
}

.stat.lives.danger b {
  color: var(--bad);
  animation: blink 1s infinite;
}

/* 勝利数は10マスのゲージで見せる */
.win-gauge {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.win-gauge small {
  font-size: 9px;
  color: var(--muted);
}

.win-gauge .segs {
  display: flex;
  gap: 2px;
}

.win-gauge i {
  width: 6px;
  height: 12px;
  background: rgba(255, 255, 255, 0.12);
  transform: skewX(-15deg);
}

.win-gauge i.on {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* 最後のマスがレイドボス */
.win-gauge i.boss {
  width: 10px;
  background: rgba(255, 79, 109, 0.45);
  box-shadow: inset 0 0 0 1px #ff4f6d;
}

.win-gauge i.boss.on {
  background: #ff4f6d;
  box-shadow: 0 0 6px #ff4f6d;
}

.hud-gum {
  padding: 3px 10px 3px 6px;
  background: rgba(0, 0, 0, 0.45);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.hud-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* ------------------------------------------------------------- 本体 */

.market-main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sec-label {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sec-label::before {
  content: "";
  width: 3px;
  height: 10px;
  background: var(--accent);
}

.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.board-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 18px;
}

.party-hp {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--good);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.party-grid {
  flex: 2.1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.bench-grid {
  flex: 0.85 1 0;
  min-height: 0;
  max-height: 96px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 5px;
  padding-top: 5px;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
}

/* ------------------------------------------------------------- 枠とカード */

.slot {
  position: relative;
  min-height: 0;
  min-width: 0;
  cursor: pointer;
  display: flex;
  overflow: visible;
  transition: transform 0.18s var(--spring);
}

.slot.empty {
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.025) 0 6px, transparent 6px 12px), rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.slot.bench.empty {
  background: rgba(0, 0, 0, 0.35);
}

.slot.droppable.empty {
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.5);
  animation: empty-wait 1.2s ease-in-out infinite;
}

@keyframes empty-wait {
  50% {
    box-shadow: inset 0 0 0 2px rgba(255, 210, 63, 0.85);
  }
}

.slot-label {
  margin: auto;
  font-family: var(--font-display);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.18);
}

.slot.selected {
  transform: translateY(-4px) scale(1.04) rotate(-1.5deg);
  z-index: 3;
}

.slot.selected {
  filter: drop-shadow(0 0 7px rgba(255, 210, 63, 0.75)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.slot.selected .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--rc);
}

.slot.match {
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.7));
}

.slot.match .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--rc);
  animation: match-pulse 1s ease-in-out infinite;
}

@keyframes match-pulse {
  50% {
    filter: brightness(1.25);
  }
}

.slot.dragover {
  transform: scale(1.04);
}

.slot.targetable {
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.7));
}

.slot.targetable .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent);
  animation: match-pulse 0.9s ease-in-out infinite;
}

.slot.arriving .unit-card {
  opacity: 0;
}

.slot.levelup {
  animation: levelup-flash 1.4s ease-out;
  z-index: 4;
}

.slot.levelup::after {
  content: "LV UP!";
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 5;
  transform: translate(-50%, -50%);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 0 0 12px rgba(255, 210, 63, 0.8);
  white-space: nowrap;
  pointer-events: none;
  animation: levelup-text 1.4s ease-out forwards;
}

@keyframes levelup-flash {
  0% {
    filter: brightness(2.2) saturate(1.5);
    transform: scale(1.12);
  }
  100% {
    filter: none;
    transform: none;
  }
}

@keyframes levelup-text {
  0% {
    opacity: 0;
    transform: translate(-50%, -10%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.25);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -150%) scale(1);
  }
}

.unit-boost {
  position: absolute;
  top: 1px;
  right: 4px;
  z-index: 2;
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 4px #000;
}

/* ユニットカード（枠の大きさに合わせて伸縮） */
.unit-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 4px 3px 3px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--rc) 45%, transparent), transparent 70%),
    linear-gradient(170deg, #343a4b, #161921 70%);
  box-shadow: inset 1px 1px 0 var(--edge-hi), inset -1px -1px 0 var(--edge-lo), inset 0 -3px 0 var(--rc);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s;
}

.unit-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--rc) 50%, transparent 50%);
  opacity: 0.9;
}

.unit-art {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 64px;
  aspect-ratio: 1;
}

.unit-img,
.material-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.55));
}

.board .unit-img {
  animation: bob 2.4s ease-in-out infinite;
  animation-delay: var(--bd, 0s);
}

.unit-kind {
  position: absolute;
  left: -5px;
  bottom: -3px;
  line-height: 0;
  filter: drop-shadow(0 1px 1px #000);
}

.unit-card .lv {
  position: absolute;
  right: -6px;
  top: -2px;
}

.unit-name {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card .pips {
  flex: none;
  margin-top: 3px;
}

/* ------------------------------------------------------------- マーケット */

.market {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.market-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rank-chip {
  flex: none;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  color: #111;
  padding: 1px 7px;
  background: var(--accent-2);
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

.rank-chip b {
  font-size: 14px;
  margin-left: 2px;
}

.odds {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 3px;
  overflow: hidden;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 10px;
}

.odds-item {
  flex: none;
  padding: 0 4px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--rc);
}

.reroll-btn,
.reroll-btn .spin {
  display: inline-block;
}

.reroll-btn:active .spin {
  animation: spin 0.4s ease-out;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.offers {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  height: clamp(84px, 14dvh, 114px);
  perspective: 600px;
}

.offer {
  position: relative;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transition: transform 0.18s var(--spring);
}

.offer.deal {
  animation: deal-in 0.45s var(--spring) both;
  animation-delay: var(--d, 0s);
}

@keyframes deal-in {
  from {
    transform: rotateY(90deg) translateY(-10px);
    opacity: 0;
  }
}

.offer .unit-card {
  flex: 1 1 auto;
  height: auto;
}

.offer.material-slot .unit-card {
  --rc: var(--accent-2);
}

.offer.selected {
  transform: translateY(-5px) scale(1.05);
  z-index: 3;
}

.offer.selected {
  filter: drop-shadow(0 0 7px rgba(255, 210, 63, 0.75));
}

.offer.selected .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--rc);
}

.offer.expensive .unit-card {
  filter: grayscale(0.7) brightness(0.6);
}

.offer.expensive .price {
  color: var(--bad);
}

/* 取り置き（1枠ずつ）。南京錠をタップで切り替え */
.offer-lock {
  position: absolute;
  top: -6px;
  right: -5px;
  z-index: 3;
  width: 24px;
  height: 24px;
  padding: 3px;
  border: 0;
  border-radius: 50%;
  color: #aab2c4;
  background: rgba(10, 12, 17, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  cursor: pointer;
}

.offer-lock.on {
  color: #241900;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
}

.offer-lock.pop {
  animation: lock-pop 0.4s var(--spring);
}

@keyframes lock-pop {
  40% {
    transform: scale(1.4) rotate(-12deg);
  }
}

.lock-icon {
  display: inline-flex;
  width: 100%;
  height: 100%;
}

.lock-icon svg {
  width: 100%;
  height: 100%;
}

/* 取り置き中: 黄色い縁と「取置」の帯。GUMが足りなくても暗くしすぎない */
.offer.locked .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--rc);
}

.offer.locked::after {
  content: "取置";
  position: absolute;
  left: -3px;
  top: 34%;
  z-index: 2;
  padding: 0 5px;
  font-family: var(--font-display);
  font-size: 10px;
  line-height: 15px;
  color: #241900;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 6px, #ffe58a 6px 12px);
  transform: rotate(-12deg);
  pointer-events: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.offer.locked.expensive .unit-card {
  filter: grayscale(0.35) brightness(0.8);
}

/* 情報バーの取り置きボタン */
.lock-action {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.lock-action .lock-icon {
  width: 14px;
  height: 14px;
}

.lock-action.on {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* GUMが足りないときの購入ボタン */
.btn.short {
  opacity: 0.6;
}

/* デッキにそのレアリティ以上のヒーローがいない枠（ストーリー） */
.offer.empty-offer {
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  cursor: help;
  background: repeating-linear-gradient(-45deg, rgba(255, 79, 109, 0.06) 0 5px, transparent 5px 10px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -3px 0 color-mix(in srgb, var(--rc, #888) 60%, transparent);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.empty-rarity {
  font-family: var(--font-num);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--rc, var(--muted));
  opacity: 0.85;
}

.offer.empty-offer small {
  font-size: 9px;
  line-height: 1.2;
  color: var(--muted);
  white-space: pre-line;
}

.offer.sold {
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.2);
  font-family: var(--font-num);
  font-weight: 700;
  letter-spacing: 0.15em;
  font-size: 11px;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 0 5px, transparent 5px 10px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  cursor: default;
}

.price {
  flex: none;
  margin-top: -2px;
  align-self: center;
  padding: 0 6px;
  background: #0b0d12;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  font-size: 12px;
  z-index: 1;
}

.owned-badge {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 2px 5px;
  background: rgba(10, 12, 17, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.6);
}

.offer.merge-ready {
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.8));
}

.offer.merge-ready .unit-card {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--rc);
  animation: match-pulse 1s ease-in-out infinite;
}

.merge-badge {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: linear-gradient(180deg, #fff1a8, var(--accent));
  color: #241900;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  padding: 0 7px;
  white-space: nowrap;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  animation: badge-bounce 0.9s ease-in-out infinite;
}

@keyframes badge-bounce {
  50% {
    transform: translateX(-50%) translateY(-3px);
  }
}

/* ------------------------------------------------------------- 情報バー */

.info-bar {
  flex: none;
  height: 86px;
  padding: 7px 9px;
  overflow: hidden;
}

.info-bar .info-page {
  height: 100%;
}

.info-bar .info-page.turn {
  animation: page-turn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transform-origin: 0 50%;
}

@keyframes page-turn {
  0% {
    opacity: 0;
    transform: perspective(500px) rotateY(-35deg) translateX(30px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.compact {
  display: flex;
  gap: 8px;
  height: 100%;
  align-items: center;
}

.compact-art {
  flex: none;
  position: relative;
  width: 68px;
  height: 68px;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--rc, var(--accent-2)) 45%, transparent), transparent 70%), #10131a;
  box-shadow: inset 0 0 0 2px var(--rc, var(--line));
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.compact-art img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.compact-art.material img {
  width: 52px;
  height: 52px;
}

.compact-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
  height: 100%;
  justify-content: center;
}

.compact-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.compact-name {
  font-family: var(--font-display);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.rarity-dot {
  flex: none;
  font-family: var(--font-num);
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  color: #111;
  background: var(--rc);
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

.faction-badge {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  color: var(--faction);
  box-shadow: inset 0 0 0 1px currentColor;
}

.boost-mark {
  color: var(--accent);
  font-weight: 700;
}

.progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-num);
  font-weight: 700;
}

.compact-fx {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  overflow: hidden;
  max-height: 46px;
}

.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px 1px 1px;
  background: rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-chip .kind-icon {
  width: 14px;
  height: 14px;
}

.trigger {
  flex: none;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 10px;
  padding: 0 4px;
  background: #143844;
  color: var(--accent-2);
}

.trigger-start {
  background: #3d3410;
  color: var(--accent);
}

.compact-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
}

.compact-actions .btn {
  padding: 7px 11px;
}

.compact-actions .action-row {
  display: flex;
  gap: 4px;
}

.compact-actions .action-row .btn {
  flex: 1;
  padding: 6px 7px;
  justify-content: center;
}

.btn.primary.merge {
  background: linear-gradient(180deg, #fff1a8, var(--accent));
  font-family: var(--font-num);
  animation: match-pulse 1s ease-in-out infinite;
}

.info-btn {
  font-size: 11px;
}

.target-hint {
  color: var(--accent);
  font-weight: 700;
  animation: blink 1.1s infinite;
}

.ext-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  min-width: 0;
}

.strip-label {
  flex: none;
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--muted);
  writing-mode: vertical-rl;
  font-size: 10px;
  letter-spacing: 0.2em;
}

.strip-empty {
  color: rgba(255, 255, 255, 0.2);
}

.ext-list {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  scrollbar-width: none;
}

.ext-list::-webkit-scrollbar {
  display: none;
}

.ext-list.center {
  justify-content: center;
  flex-wrap: wrap;
  max-height: 112px;
  overflow-y: auto;
}

.ext-icon {
  flex: none;
  position: relative;
  width: 46px;
  height: 46px;
  background: radial-gradient(circle, rgba(255, 210, 63, 0.18), transparent 70%), #12151c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  cursor: pointer;
}

.ext-icon img {
  width: 42px;
  height: 42px;
  margin: 2px;
}

.ext-count {
  position: absolute;
  right: 0;
  bottom: 0;
  font-family: var(--font-num);
  font-size: 10px;
  background: var(--accent);
  color: #000;
  padding: 0 3px;
  font-weight: 700;
}

/* 「同じヒーロー3体 → Lv2」の図解 */
.merge-guide {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  border: 0;
  background: rgba(255, 210, 63, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.45);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  cursor: pointer;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: 1px;
}

.guide-unit {
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0.3;
}

.guide-unit.on {
  opacity: 1;
}

.guide-arrow {
  color: var(--accent);
  margin: 0 2px;
  animation: arrow-nudge 1s ease-in-out infinite;
}

@keyframes arrow-nudge {
  50% {
    transform: translateX(3px);
  }
}

.guide-lv {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 13px;
  color: #0d1a10;
  padding: 0 4px;
  background: var(--good);
}

.guide-caption {
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
}

/* ------------------------------------------------------------- バトル開始ボタン */

.market-footer {
  flex: none;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 10px max(8px, env(safe-area-inset-bottom));
}

.battle-btn {
  position: relative;
  width: 100%;
  height: 52px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  background: linear-gradient(100deg, #ff3d6e, #ff7a3d);
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}

.battle-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-60deg, rgba(255, 255, 255, 0.12) 0 10px, transparent 10px 22px);
  animation: stripes-drift 3s linear infinite;
  pointer-events: none;
}

.battle-btn::after {
  content: "▶▶";
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  letter-spacing: -2px;
  animation: arrow-nudge 0.8s ease-in-out infinite;
}

.battle-btn.off {
  filter: grayscale(0.85) brightness(0.6);
}

/* まだ買えるヒーローが残っている間は控えめに（先に強化してほしいので） */
.battle-btn.wait {
  color: #d6dbe6;
  background: linear-gradient(100deg, #4a3040, #4a3a30);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 61, 0.45);
}

.battle-btn.wait::before,
.battle-btn.wait::after {
  animation: none;
  opacity: 0.4;
}

/* 買えるヒーロー（GUMが足りて置き場所がある）に細い縁 */
.offer.buyable:not(.selected):not(.locked) .unit-card {
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.7), inset 0 -3px 0 var(--rc);
}

.battle-btn.off::before,
.battle-btn.off::after {
  animation: none;
}

@media (max-height: 640px) {
  .hud {
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .hud-avatar {
    width: 34px;
    height: 34px;
  }

  .stat b {
    font-size: 16px;
  }

  .info-bar {
    height: 76px;
  }

  .compact-art {
    width: 58px;
    height: 58px;
  }

  .compact-art img {
    width: 54px;
    height: 54px;
  }

  .battle-btn {
    height: 46px;
    font-size: 20px;
  }

  .party-grid .unit-name,
  .bench-grid .unit-name {
    display: none;
  }
}

@media (max-width: 380px) {
  .win-gauge i {
    width: 4px;
  }

  .hud {
    gap: 5px;
  }

  .gum.big {
    font-size: 17px;
  }
}
