/* --- ページ全体 --- */
.page {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.page.hidden-left {
  transform: translateX(-100%);
  opacity: 0;
}

.page.hidden-right {
  transform: translateX(100%);
  opacity: 0;
}

.page.visible {
  transform: translateX(0);
  opacity: 1;
}

/* --- 共通グリッド（キャラ・アイテム両対応） --- */
.select-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 20px;
  width: 80%;
  max-width: 900px;
  margin: 30px auto 20px auto;
  justify-items: center;
  align-items: center;
}

/* --- カード共通（キャラ・アイテム） --- */
.charCard, .itemCard {
  width: 150px;
  height: 150px;
  background: #222;
  border-radius: 18px;
  border: 3px solid rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
}

.charCard img, .itemCard img {
  width: 100px;
  height: 100px;
  border-radius: 10%;
  object-fit: cover;
  margin-bottom: 5px;
}

.charCard small, .itemCard small {
  font-size: 0.75rem;
  color: #ccc;
  text-align: center;
  line-height: 1;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 選択時ハイライト --- */
.charCard.selected, .itemCard.selected {
  transform: scale(1.1);
  box-shadow: 0 0 25px 8px gold;
  z-index: 10;
}

/* --- レア度別枠色（キャラ用） --- */
.charCard[data-rarity="N"] { border-color: gray; }
.charCard[data-rarity="R"] { border-color: aqua; }
.charCard[data-rarity="SR"] { border-color: gold; }
.charCard[data-rarity="SSR"] {
  border-image: conic-gradient(red, orange, yellow, green, blue, purple, red) 1;
  border-style: solid;
  border-width: 3px;
}

/* --- 出撃ボタン --- */
#deployBtn {
  background: linear-gradient(45deg, #ff9500, #ff5e3a);
  color: #fff;
  border: none;
  padding: 12px 25px;
  font-size: 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
#deployBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#deployBtn:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px #ff9500;
}

/* --- ステージボタン --- */
#stages {
  top: 20%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 30px 0;
}

.stageBtn {
  background: #222;
  color: #fff;
  font-size: 1rem;
  padding: 15px 25px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.stageBtn:hover:not(:disabled) {
  background: #333;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.stageBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #111;
}
.deployBtn {
  background: linear-gradient(45deg, #ff9500, #ff5e3a);
  color: #fff;
  border: none;
  padding: 12px 25px;
  font-size: 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.deployBtn:hover:not(:disabled) {
background-color: #c03;
}

.deployBtn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* --- 768px以下用レスポンシブ --- */
@media screen and (max-width: 768px) {
  /* 横の謎スクロール対策（translateXでのはみ出し封じ） */
html, body { overflow-x: hidden; }
.page { overflow-x: hidden;
    position: relative;
    top: auto; left: auto;
    width: 100%;
    min-height: auto;
    transition: transform 0.5s ease, opacity 0.5s ease;
  }

  .page.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
  }

  .page.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .teaming {
    display: none;
  }
  /* グリッドは「列幅=カード幅」に統一して崩れ防止 */
  .select-grid{
    width: 100%;
    padding: 0 12px;            /* 端末端のはみ出し防止 */
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
  }

  /* カード幅はグリッドに合わせる（28vwを捨てる） */
  .charCard, .itemCard{
    width: 100%;
    max-width: none;
    aspect-ratio: 1 / 1;        /* 正方形固定 */
    height: auto;               /* 150px等が残ってても潰す */
    position: relative;         /* selectedのz-index安定 */
  }

  .charCard img, .itemCard img {
    width: 60%;
    height: auto;
    border-radius: 50%;
    margin-bottom: 5px;
  }

  .charCard small, .itemCard small {
    font-size: 0.75rem;
    white-space: normal;
  }
  /* --- 選択時ハイライト --- */
  .charCard.selected, .itemCard.selected {
    transform: scale(1.1);
    box-shadow: 0 0 15px 3px gold;
    z-index: 10;
  }

  #deployBtn {
    width: 80%;
    font-size: 0.95rem;
    padding: 10px 20px;
    margin: 10px auto;
    display: block;
  }

  #stages {
    top: auto;
    gap: 10px;
    width: 70%;
    margin: 20px auto;
  }


  .stageBtn {
    background: #222;
    color: #fff;
    font-size: 0.95rem;
    padding: 12px 0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
  }

  .stageBtn:hover:not(:disabled) {
    background: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  }

  .stageBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #111;
  }
}
