/* ===== 手番の流れセクション ===== */
.turn-flow-section {
  height: 1500vh; /* 400vh → 450vh に延長（手札カード表示のため） */
  min-height: 1300vh;
  position: relative;
  background: var(--bg);
  --section-title-top: clamp(7%, 9vh, 11%);
  --section-title-left: clamp(8%, 12vw, 16%);
  --section-title-max-width: clamp(18rem, 32vw, 28rem);
  --section-title-gap: 0.7rem;
  --section-title-body-color: rgba(110, 106, 99, 0.85);
  --section-title-body-line-height: 1.8;
}

.turn-flow-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
}

/* === ゲームボード（小さめ） === */
.turn-flow-board {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem; /* カード間の距離 */
  opacity: 0;
  z-index: 3;
  flex-wrap: nowrap; /* 改行しない */
}

/* === 道カード用のスタイル === */
.turn-flow-card {
  position: relative;
  flex-shrink: 0; /* 縮小しない */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px; /* 初期配置より小さく */
  height: 84px;
  opacity: 0;
  transform: scale(0.6);
}

.turn-flow-inserted-card {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  /* wrapper は回転させない（他の道路カードと同じにする） */
  transform: none;
  transform-origin: 50% 50%;
  visibility: hidden;
}

.turn-flow-card img {
  position: relative;
  z-index: 1;
  width: 60px;
  height: auto;
  transform: rotate(90deg); /* 90度回転 */
  border-radius: 5px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  display: block;
  transform-origin: center;
  backface-visibility: hidden; /* 裏面を隠す */
}

/* === 王カード用スタイル === */
.turn-flow-king {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 84px;
  opacity: 0;
  transform: scale(0.6);
}

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

.turn-flow-king:last-child {
  margin-left: 1.2rem;
}

.turn-flow-king img {
  width: 42px; /* 初期配置より小さく */
  height: auto;
  display: block;
  background: transparent;
  object-fit: contain;
  transform-origin: center;
  backface-visibility: hidden;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
  /* 王カードは回転しない */
}

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

/* 兵士コマ配置エリア：街カードの中央に重ねて配置 */
.turn-flow-pieces-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 8px; /* 初期配置より小さく */
  pointer-events: none; /* カードのクリックを妨げない */
  opacity: 0;
  z-index: 1200;
}

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

/* コマの行配置 */
.turn-flow-pieces-row {
  display: flex;
  justify-content: center;
  gap: 7px; /* 初期配置より小さく */
}

.turn-text {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.turn-text p{
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 600;
  margin: 0;
}

.turn-text--compact {
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  line-height: 1.5;
}

@media (max-width: 480px) {
  .turn-text--compact {
    font-size: clamp(0.85rem, 4vw, 0.9rem);
  }
}

/* 個別のコマスタイル */
.turn-flow-piece {
  position: relative;
  width: 24px; /* 初期配置より小さく */
  height: 24px;
  border-radius: 50%; /* 円形 */
  overflow: hidden;
  opacity: 0; /* 初期状態で非表示 */
  transform: scale(0) rotate(180deg); /* 初期状態：縮小+回転 */
  z-index: 1300;
}

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

/* === 手番カード配置エリア === */
.turn-card-area {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}

.turn-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px; /* ボードよりも少し大きめ */
  height: 112px;
  opacity: 0;
  transform: scale(0.5) translateY(50px);
}

.turn-card img {
  width: 80px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: block;
  transform-origin: center;
  backface-visibility: hidden;
}

/* === 手番：ハイライト用SVG === */
.turn-flow-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;           /* ボード(3)・カード(4)より前 */
  pointer-events: none; /* クリックなどを邪魔しない */
}

.turn-flow-svg .outline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0; /* 初期は非表示（JSで出す） */
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.15));
}

/* === 手札カード5枚エリア === */
.hand-cards-area {
  position: absolute;
  bottom: 16%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3.5rem;
  z-index: 3;
}

.hand-card {
  position: relative;
  opacity: 0;
  transform: none;
  transform-origin: center center;
}

.turn-flow-start-marker{
  position: absolute;
  bottom: -20px;
  right: 4px;
  width: clamp(20px, 4vw, 32px);
  height: auto;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  z-index: 20;        /* カードより前面 */
}

.hand-public-area {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: clamp(2.4rem, 5vw, 7rem);
  pointer-events: none;
  z-index: 9;
}

.hand-public-card {
  position: relative;
  transform-origin: center;
  opacity: 0;
  transform: scale(0.9);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.hand-public-card:nth-child(3) {
  margin-left: clamp(3.6rem, 8vw, 6.4rem);
}

.hand-public-card img {
  display: block;
  width: clamp(52px, 6.5vw, 70px);
  height: auto;
  border-radius: 5px;
}

.turn-flow-start-marker img{
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0; 
  filter: none; /* 影を削除 */
  background: transparent; /* 背景透明化 */
}

#turn-flow .turn-flow-start-marker img,
#turn-flow .start-player-marker img { /* どちらのクラスでも効くように */
  box-shadow: none !important;
  width: clamp(22px, 4.2vw, 34px);
}

/* 4,5枚目のカードを180度回転させる */
#hand-card-4 img,
#hand-card-5 img {
  transform: rotate(180deg);
}

.hand-card img {
  width: clamp(60px, 8vw, 80px);
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
}

/* .hand-card img:hover {
  transform: translateY(-5px);
} */

#turn-flow .turn-flow-start-marker img,
#turn-flow .start-player-marker img { /* どちらのクラスでも効くように */
  width: clamp(32px, 6.2vw, 52px);
  filter: none; /* 影を削除 */
  background: transparent; /* 背景透明化 */
}

/* === レスポンシブ対応 === */
/* タブレット（768px以下） */
@media (max-width: 768px) {
  .turn-flow-start-marker{ bottom:-10px; right:-10px; }
  .hand-cards-area {
    gap: 2.5rem;
    bottom: 20%;
  }

  .hand-card img {
    width: clamp(50px, 7vw, 70px);
  }

  .turn-flow-svg .outline { stroke-width: 5.0; }
  .turn-flow-section {
    --section-title-top: 8%;
    --section-title-left: 10%;
    --section-title-max-width: min(82vw, 24rem);
  }

  .turn-flow-board {
    top: 30%;
    gap: 1.8rem;
  }

  .turn-flow-card {
    width: 45px;
    height: 63px;
  }

  .turn-flow-card img {
    width: 45px;
    border-radius: 4px;
  }

  .turn-flow-king {
    width: 30px;
    height: 41px;
  }

  .turn-flow-king:first-child {
    margin-right: 0.5rem;
  }

  .turn-flow-king:last-child {
    margin-left: 0.5rem;
  }

  .turn-flow-king img {
    width: 30px;
  }

  .turn-flow-pieces-container {
    gap: 5px;
  }

  .turn-flow-pieces-row {
    gap: 5px;
  }

  .turn-flow-piece {
    width: 19px;
    height: 19px;
  }

  /* 手番カード タブレット対応 */
  .turn-card-area {
    bottom: 25%;
  }

  .turn-card {
    width: 56px;
    height: 63px;
  }

  .turn-card img {
    width: 53px;
    height: auto;
    border-radius: 4px;
  }
}

/* スマートフォン（480px以下） */
@media (max-width: 480px) {
  .turn-flow-start-marker{ bottom:-8px; right:-8px; }
  .turn-flow-svg .outline { stroke-width: 7; }
  .turn-flow-section {
    --section-title-top: 10%;
    --section-title-left: 8%;
    --section-title-max-width: min(88vw, 22rem);
  }

  .hand-cards-area {
    gap: 1.8rem;
    bottom: 25%;
  }
  
  .hand-card img {
    width: clamp(45px, 6vw, 60px);
  }

  .turn-flow-board {
    top: 35%;
    gap: 1.1rem;
    max-width: 92vw;
  }

  .turn-flow-card {
    width: 32px;
    height: 44px;
  }

  .turn-flow-card img {
    width: 100%;
    border-radius: 3px;
  }

  .turn-flow-king {
    width: 20px;
    height: 32px;
  }

  .turn-flow-king img {
    width: 100%;
  }

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

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

  .turn-flow-pieces-container {
    gap: 3px;
  }

  .turn-flow-pieces-row {
    gap: 3px;
  }

  .turn-flow-piece {
    width: 13px;
    height: 13px;
  }

  /* 手番カード スマホ対応 */
  .turn-card-area {
    bottom: 30%;
  }

  .turn-card {
    width: 50px;
    height: 42px;
  }

  .turn-card img {
    width: 50px;
    border-radius: 3px;
  }
}

/* 極小スマートフォン（360px以下） */
@media (max-width: 360px) {
  .turn-flow-start-marker{ bottom:-8px; right:-8px; }
  .hand-cards-area {
    gap: 1rem;
    bottom: 25%;
  }


  .hand-card img {
    width: clamp(40px, 6vw, 60px);
  }

  
  .turn-flow-section {
    --section-title-top: 9%;
    --section-title-left: 6%;
    --section-title-max-width: min(92vw, 20rem);
  }

  .turn-flow-board {
    top: 33%;
    gap: 0.45rem;
    max-width: 94vw;
  }

  .turn-flow-card {
    width: 18px;
    height: 26px;
  }

  .turn-flow-card img {
    width: 100%;
    border-radius: 2px;
  }
  

  .turn-flow-king {
    width: 16px;
    height: 24px;
  }

  .turn-flow-king img {
    width: 100%;
  }

  .turn-flow-piece {
    width: 10px;
    height: 10px;
  }

  .turn-flow-pieces-container {
    gap: 2px;
  }

  .turn-flow-pieces-row {
    gap: 2px;
  }

  /* 手番カード 極小スマホ対応 */
  .turn-card-area {
    bottom: 35%;
  }

  .turn-card {
    width: 40px;
    height: 33px;
  }

  .turn-card img {
    width: 40px;
    border-radius: 2px;
  }

  .turn-flow-svg .outline {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0; /* 初期は非表示（JSで出す） */
    filter: drop-shadow(0 1px 0 rgba(0,0,0,.15));
  }
}
