/* すべての要素に対してボックスサイズをborder-boxに設定（paddingやborderを含めたサイズ計算にする） */
/* タップ時のハイライト（スマホの青い表示）を無効化 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* html全体の余白をなくし、高さを100%に設定 */
html {
  margin: 0;
  height: 100%;
}

/* bodyの基本スタイル設定（中央寄せレイアウト） */
body {
  margin: 0;
  height: 100vh;
  font-family: sans-serif;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ゲーム全体を囲むコンテナ */
.container {
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  background-image: url("assets/bg.png");
  background-size: cover;
  background-position: center;
  user-select: none;
  -webkit-user-select: none;
}

/* ヘッダー部分（スコア表示など） */
.game-header {
  height: 50px;
  padding: 10px 14px;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
}

/* スコアなどの情報エリア */
.info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: bold;
  width: 100%;
  font-size: 20px;
}

/* 空白スペース用（レイアウト調整） */
.header-spacer {
  display: inline-block;
}

/* メインのゲームエリア */
.game-main {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
}

/* ボタンの基本デザイン */
.btn {
  padding: 18px 40px;
  font-size: 24px;
  font-weight: bold;
  border: none;
  border-radius: 999px;
  background: #18c56e;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px #0e9f56;
  transition: all 0.15s ease;
}

/* ボタンにホバーしたとき */
.btn:hover {
  background: #1edc7c;
}

/* ボタンをクリックしたときの押し込み表現 */
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px #0e9f56;
}

/* ゲームパネル（カード表示部分） */
.game-panel {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 18px 18px;
  position: relative;
}

/* メッセージ表示（正解・不正解など） */
.message {
  margin-top: 2px;
  min-height: 32px;
  font-size: 22px;
  font-weight: bold;
  color: #e11d48;
  text-align: center;
}

/* カードを並べるグリッドレイアウト */
.game-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr)); 
  gap: 14px;
  width: min(100%, 800px);
  margin-top: 40px;
  perspective: 1000px;
}

/* 各カードの基本スタイル */
.card {
  aspect-ratio: 3 / 4;
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.2s ease;
  cursor: pointer;
}

/* カードがめくられた状態 */
.card.flip {
  transform: rotateY(180deg);
}

/* マッチ済みカード */
.card.matched {
  cursor: default;
}

/* ホバー時（まだめくられていないカード） */
.card:not(.flip):not(.matched):hover {
  opacity: 0.7;
  transform: translateY(-4px);
}

/* カードの表と裏の共通スタイル */
.card-front,
.card-back {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  border-radius: 14px;
  border: 3px solid #16a34a;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  backface-visibility: hidden;
}

/* カード表面（文字側） */
.card-front {
  background-color: #ffffff;
  transform: rotateY(180deg);
  font-size: 42px;
  color: #15803d;
}

/* カード裏面（画像） */
.card-back {
  background-image: url("assets/card-back.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
  font-size: 0;
}

/* マッチしたカードの見た目 */
.card.matched .card-front {
  background-color: #bbf7d0;
  border-color: #22c55e;
  color: #15803d;
}

/* 結果表示画面 */
.result {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  padding: 20px;
}

/* 結果タイトル */
.result-title {
  margin: 0;
  font-size: 34px;
}

/* 結果テキスト */
.result-text {
  margin: 0;
  font-size: 30px;
  font-weight: bold;
}

/* 新記録表示 */
.new-record {
  font-size: 24px;
  font-weight: bold;
  color: #f59e0b;
  margin: 4px 0;
  min-height: 32px;
}

/* スマホなど小さい画面用の調整 */
@media (max-width: 700px) {
  .info {
    font-size: 18px;
  }

  .message {
    font-size: 20px;
  }

  .game-board {
    width: min(100%, 500px);
    gap: 8px;
  }

  .card-front {
    font-size: 34px;
  }

}