/* ===== 初期配置セクション ===== */
.setup-section {
  height: 300vh; /* 3倍の高さ */
  position: relative;
  background: var(--light);
  --section-title-top: clamp(6%, 9vh, 11%);
  --section-title-left: clamp(8%, 12vw, 16%);
  --section-title-max-width: clamp(18rem, 28vw, 26rem);
}

/* 初期配置コンテナ */
.setup-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  gap: 2rem;
}

/* === ゲームボード全体 === */
.game-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3.5rem; /* カード間の距離 */
  position: relative;
  z-index: 2;
  opacity: 1;
  flex-wrap: nowrap; /* 改行しない */
}

/* === 個別カード配置 === */
/* 道カード用のスタイル */
.board-card {
  flex-shrink: 0; /* 縮小しない */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 140px;
}

.board-card img {
  width: 100px;
  height: auto;
  transform: rotate(90deg); /* 90度回転 */
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  display: block;
  transform-origin: center;
  backface-visibility: hidden; /* 裏面を隠す */
}

/* === 王カード用スタイル === */
.board-king {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 140px;
}

/* 王コマを左右に少し離して配置 */
.board-king:first-child {
  margin-right: 2rem;
}

.board-king:last-child {
  margin-left: 2rem;
}

.board-king img {
  width: 70px;
  height: auto;
  display: block;
  background: transparent;
  object-fit: contain;
  transform-origin: center;
  backface-visibility: hidden;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.24));
  /* 王カードは回転しない */
}

/* === SVGアニメーションレイヤー === */
.setup-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10; /* カードより上に表示 */
}

/* 初期配置セクションの線スタイル */
.setup-svg .line {
  stroke: var(--accent);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linecap: butt; /* 重複設定：butt が優先 */
}

/* 初期配置セクションのラベルスタイル */
.setup-svg .label {
  fill: var(--ink);
  font-size: 20px;
  font-weight: 500;
  opacity: 0;
}

/* === 街カードと兵士コマ === */
/* 街カードコンテナを相対位置に設定 */
.city-card-container {
  position: relative;
}

/* 兵士コマ配置エリア：街カードの中央に重ねて配置 */
.pieces-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none; /* カードのクリックを妨げない */
}

/* 街カード内のコマ画像は回転させない */
.pieces-container .piece img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: none !important; /* 回転を強制的に無効化 */
}

/* コマの行配置 */
.pieces-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* 個別のコマスタイル */
.piece {
  width: 36px;
  height: 36px;
  border-radius: 50%; /* 円形 */
  overflow: hidden;
  opacity: 0; /* 初期状態で非表示 */
  transform: scale(0) rotate(180deg); /* 初期状態：縮小+回転 */
}

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

/* ===== レスポンシブ対応 ===== */

/* === 大型デスクトップ（1200px以上） === */
@media (min-width: 1200px) {
  .setup-container {
    gap: 2.5rem;
  }

  .game-board {
    gap: 4rem;
  }

  .board-card {
    width: 110px;
    height: 154px;
  }

  .board-card img {
    width: 110px;
  }

  .board-king {
    width: 110px;
    height: 154px;
  }

  .board-king img {
    width: 77px;
  }

  .setup-svg .label {
    font-size: 26px;
  }

  .piece {
    width: 40px;
    height: 40px;
  }

  .pieces-container {
    gap: 14px;
  }

  .pieces-row {
    gap: 12px;
  }
}

/* === タブレット（768px以下） === */
@media (max-width: 768px) {
  .setup-container {
    padding: 0.3rem;
    gap: 1.5rem;
  }

  .game-board {
    gap: 1.7rem;
    max-width: 85%;
  }
  
  .board-card {
    width: 50px;
    height: 68px;
  }
  
  .board-card img {
    width: 50px;
    border-radius: 6px;
  }

  .board-king {
    width: 50px;
    height: 68px;
  }

  .board-king:first-child {
    margin-right: 0.8rem;
  }

  .board-king:last-child {
    margin-left: 0.8rem;
  }
  
  .board-king img {
    width: 38px;
  }

  .setup-svg .line {
    stroke-width: 4;
  }

  .setup-svg .label {
    font-size: 20px;
    font-weight: 600;
  }

  .pieces-container {
    gap: 6px;
  }
  
  .pieces-row {
    gap: 6px;
  }
  
  .piece {
    width: 18px;
    height: 18px;
  }
}

/* === スマートフォン（480px以下） === */
@media (max-width: 480px) {
  .setup-container {
    padding: 0 2.5rem;
    gap: 1rem;
  }

  .game-board {
    gap: 1.3rem;
    max-width: 80%;
  }
  
  .board-card {
    width: 36px;
    height: 50px;
  }
  
  .board-card img {
    width: 36px;
    border-radius: 4px;
  }

  .board-king {
    width: 36px;
    height: 50px;
  }
  
  .board-king img {
    width: 28px;
  }

  .board-king:first-child {
    margin-right: 0.1rem;
  }

  .board-king:last-child {
    margin-left: 0.1rem;
  }

  .setup-svg .line {
    stroke-width: 5;
  }

  .setup-svg .label {
    font-size: clamp(22px, 5.6vw, 28px);
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .pieces-container {
    gap: 4px;
  }
  
  .pieces-row {
    gap: 3px;
  }
  
  .piece {
    width: 14px;
    height: 14px;
  }
}

/* === 極小スマートフォン（360px以下） === */
@media (max-width: 360px) {
  .setup-container {
    padding: 0 2rem;
  }

  .game-board {
    gap: 1.0rem;
    max-width: 75%;
  }
  
  .board-card {
    width: 28px;
    height: 39px;
  }
  
  .board-card img {
    width: 28px;
    border-radius: 3px;
  }

  .board-king {
    width: 28px;
    height: 39px;
  }
  
  .board-king img {
    width: 22px;
  }

  .setup-svg .line {
    stroke-width: 6;
  }

  .setup-svg .label {
    font-size: clamp(20px, 6vw, 26px);
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .piece {
    width: 10px;
    height: 10px;
  }

  .pieces-container {
    gap: 2px;
  }
  
  .pieces-row {
    gap: 2px;
  }
}
