/* しんけいすいじゃく（party/pairs） 独自スタイル。共通は ../common/party.css。
   テーマ色は深緑系（カードテーブル。party.css の共通CSS変数を上書き）。 */

:root {
  --party-accent: #2e7d5b;
  --party-accent-dark: #1b5e42;
  --party-bg: #e8f3ec;
  --party-card: #ffffff;
  --pairs-table: #1f5c42;
  --pairs-table-line: #2e7d5b;
  --pairs-card-back: #2e7d5b;
  --pairs-card-back2: #256b4d;
  --pairs-gold: #f2b705;
}

.pairs-game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--pairs-table);
  overflow: hidden;
  touch-action: manipulation;
}

/* ---- 上部: 手番バナー＋プレイヤーストリップ ---- */
.pairs-top {
  flex-shrink: 0;
  padding: calc(env(safe-area-inset-top) + 10px) 10px 8px;
  text-align: center;
}

.pairs-banner {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: bold;
  color: #fff;
  min-height: 1.5em;
}

.pairs-banner.is-my-turn {
  color: var(--pairs-gold);
  animation: pairs-banner-pop 0.5s ease-out;
}

@keyframes pairs-banner-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pairs-players {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.pairs-player {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid transparent;
}

.pairs-player__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.pairs-player__score {
  min-width: 1.2em;
  text-align: center;
}

.pairs-player.is-turn {
  border-color: var(--pairs-gold);
  background: rgba(242, 183, 5, 0.22);
  box-shadow: 0 0 10px rgba(242, 183, 5, 0.6);
}

.pairs-player.is-absent {
  opacity: 0.4;
}

/* ---- 盤面 ---- */
.pairs-board {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 10px);
  align-content: center;
  justify-content: center;
}

.pairs-board[data-count="24"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pairs-board[data-count="36"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* ---- カード ---- */
.pairs-card {
  aspect-ratio: 3 / 4;
  perspective: 600px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  /* Chromeの<button>は既定で子孫の高さ%解決に失敗する内部匿名ボックスを持つ
     （heightがautoとみなされ、height:100%の子が0に潰れる）。display:gridで
     button自身の箱組みを乗っ取り、単独の子(inner)をgrid stretchで確実に
     border-box全体へ伸ばす */
  display: grid;
}

.pairs-card:disabled {
  cursor: default;
}

.pairs-card-inner {
  position: relative;
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.pairs-card.is-flipped .pairs-card-inner {
  transform: rotateY(180deg);
}

.pairs-card.is-shaking .pairs-card-inner {
  animation: pairs-shake 0.5s ease-in-out;
}

@keyframes pairs-shake {
  0%, 100% { transform: translateX(0) rotateY(0deg); }
  20% { transform: translateX(-4px) rotateY(0deg); }
  40% { transform: translateX(4px) rotateY(0deg); }
  60% { transform: translateX(-3px) rotateY(0deg); }
  80% { transform: translateX(3px) rotateY(0deg); }
}

.pairs-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  backface-visibility: hidden;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.pairs-card-back {
  background: linear-gradient(135deg, var(--pairs-card-back), var(--pairs-card-back2));
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.55);
  font-size: 1.3rem;
}

.pairs-card-front {
  background: #fff;
  transform: rotateY(180deg);
  font-size: min(7vw, 2.2rem);
}

.pairs-card.is-captured {
  visibility: hidden;
}

.pairs-card.is-wrong .pairs-card-front {
  background: #ffe0e0;
}

.pairs-card.is-correct .pairs-card-front {
  background: #dff5e6;
}

/* ---- 最終結果 ---- */
.pairs-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  background: rgb(15, 40, 28); /* 不透明。背後の手番バナー等がゴースト表示されないように */
  box-sizing: border-box;
}

.pairs-final-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  margin: 0;
}

.pairs-podium {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 320px;
}

.pairs-podium-item {
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font-size: 1.15rem;
  font-weight: bold;
  background: var(--party-card, #fff);
}

.pairs-podium-1 {
  background: #fff3c4;
  font-size: 1.4rem;
}
.pairs-podium-2 {
  background: #f0f0f0;
}
.pairs-podium-3 {
  background: #ffe0c2;
}

.pairs-final-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  color: #fff;
}

.pairs-final-list li {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
  text-align: left;
}

.pairs-final-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 320px;
}

.pairs-final-actions button {
  flex: 1;
  min-height: 56px;
  padding: 0 1rem;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: bold;
}

#btn-again {
  background: var(--party-accent, #2e7d5b);
  color: #fff;
}

#btn-back-lobby {
  background: #fff;
  color: var(--party-accent-dark, #1b5e42);
}

.pairs-wait {
  color: #fff;
  font-weight: 700;
}
