body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #222;
  color: #fff;
  text-align: center;
  height: 100%;

  /*overflow: hidden;*/
  touch-action: none; /* ← iOS Safariでのズーム・スクロール抑止 */
  overscroll-behavior: none;
}

.hidden {
  display: none;
}

.screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
/* 最初のボタン画面 */
.init-screen {
  position: relative;
  z-index: 10;
}

#bubbleCanvas {

  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  /*height: calc(var(--vh, 1vh) * 100);*/
  z-index: 0;
  pointer-events: none; /* ←これも重要！クリックを通す */
}
@media screen and (max-width: 768px) {
  canvas#bubbleCanvas {
    position: fixed; /* ← スクロールに影響されない */
    height: 100%;
  }
}
/* 最初のスタートボタン*/
.start-button {
  position: relative;
  z-index: 1;
  padding: 16px 32px;
  font-size: clamp(20px, 5vw, 28px);
  border: none;
  border-radius: 50px;
  background: linear-gradient(145deg, #e0c3fc, #8ec5fc);
  color: #222;
  font-weight: bold;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  cursor: pointer;
  letter-spacing: 1px;
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 20px rgba(0,0,0,0.3);
}


#merge-animation-area{
  position: relative;
  z-index: 1;
}





/* タイトルロゴ */
.logo {
  width: 60%; /* もしくは max-width: 400px; など */
  max-width: 400px;
  opacity: 0;
  animation: fadeInOut 5s ease-in-out forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* タイトル画像 */
.title-screen {
  position: relative;
  width: 100%;
  max-width: 1000px; /* 固定サイズ or 任意の比率 */
  aspect-ratio: 1000 / 700; /* 画像と同じ比率に保つ */
  margin: 0 auto;
}
.title-wrapper {
  position: relative;
  background-image: url("./assets/img/title.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.bg-img {
  position: relative;
  width: 100%;
  height: auto;
  display: block;
}
.title-bg {
  width: 100%;
  height: auto;
  object-fit: contain;
}
/* タイトルフェードインアニメーション */
.fade-in {
  animation: fadeInSmooth 1.5s ease-in forwards;
  opacity: 0; /* 初期は透明 */
}
@keyframes fadeInSmooth {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 上下半分を高さ割合で分割（比率調整可能） */
.title-top-half,
.title-bottom-half {
  position: absolute;
  left: 0;
  width: 100%;
}

/* 上部（例えば60%） */
.title-top-half {
  top: 0;
  height: 53%;
}

/* 下部（残り40%） */
.title-bottom-half {
  bottom: 0;
  height: 47%;
  display: flex;
  flex-direction: column;
  justify-content: top;
  align-items: center;
  gap: 0.3rem;
}

#lang-select-box{
  margin-top: 0.2vw;
  font-size: 2vw;
  color: #000;
}



#lang-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: #f9fafb;
  color: #333;
  font-size: 2vw;
  border: 1px solid #ccc;
  padding: 2px 15px 2px 15px;
  border-radius: 8px;
  font-size: 1.7vw;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}


/* オープニング：STARTボタン */
.menu-button {

  /*position: absolute;*/
  /*top: 68%;     /* ← 赤線の位置に合わせる */
  /*left: 50%;*/
  /*transform: translate(-50%, -50%);*/
  width: 18%;   /* ← 青線の幅に合わせる */
  /*padding: 8px;*/
  padding: 0.5vw 1.5vw;
  font-size: 1.2vw;
  border-radius: 14px;
  border: none;
  background: linear-gradient(to right, #fca311, #ff7f50);
  color: white;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.menu-button:hover {
  box-shadow: 3px 6px 12px rgba(0,0,0,0.6);
}
/* オープニング：オプションボタン */
.menu-button-otion {
  /*position: absolute;
  /*top: 63%;     /* ← 赤線の位置に合わせる */
  /*left: 50%;*/
  /*transform: translate(-50%, -50%);*/
  width: 18%;   /* ← 青線の幅に合わせる */
  /*padding: 8px;*/
  padding: 0.5vw 1.5vw;
  font-size: 1.2vw;
  border-radius: 14px;
    border: none;
  background: linear-gradient(to right, #6d6b6b, #adabab);
  color: white;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.4);
  /*transition: transform 0.2s, box-shadow 0.2s;*/
  /*cursor: pointer;*/
}
.menu-button-otion:hover {
  box-shadow: 3px 6px 12px rgba(0,0,0,0.6);
}
/* オープニング：履歴 */
.menu-button-histry {
  /*position: absolute;*/
  /*top: 98%;     /* ← 赤線の位置に合わせる */
  /*left: 50%;*/
  /*transform: translate(-50%, -50%);*/
  width: 18%;   /* ← 青線の幅に合わせる */
  /*padding: 8px;*/
  padding: 0.5vw 1.5vw;
  font-size: 1.2vw;
  border-radius: 14px;
  border: none;
  background: linear-gradient(to right, #6d6b6b, #adabab);
  color: white;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.menu-button-histry:hover {
  box-shadow: 3px 6px 12px rgba(0,0,0,0.6);
}

/*===================================================*/
/* ■ オプション画面                                   */
/*===================================================*/
.option-screen {
  position: relative;
  width: 100%;
  height: 100vh; /* vhで確実に画面の高さにする！ */
  display: flex;
  justify-content: center; /* 横中央 */
  align-items: center;     /* 縦中央 */
}
.option-wrapper {
  position: relative; /* 親要素にposition: relativeを追加 */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;

}
/* オプション背景 */
.option-bg {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* 上下半分を高さ割合で分割（比率調整可能） */
.option-top-half,
.option-bottom-half {
  position: absolute;
  left: 0;
  width: 100%;
}

/* 上部（例えば60%） */
.option-top-half {
  top: 0;
  height: 33%;
}

/* 下部（残り40%） */
.option-bottom-half {
  bottom: 0;
  height: 67%;
  display: flex;
  flex-direction: column;
  justify-content: top;
  align-items: center;
  gap: 0.3rem;
}



#option-wrapper-bottom{
  position: absolute;
  top: 0;
  width: 100%;
  height: 80%;
}

#option-label input[type="checkbox"] {
  background-color: #ffcc00; /* チェックボックスの背景色 */
  border: 2px solid #000; /* ボーダー色 */
  width: 20px;
  height: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* 左寄せ */
}
#option-label label {
  display: flex;
  align-items: center; /* チェックボックスとテキストを横並びに */
  margin-bottom: 0.5rem; /* 各項目の間隔を調整 */
}

/* オプション：ラベルのスタイル */
#option-label span {
  color: rgb(0, 0, 0);
  font-size: 2.5vw;
  font-weight: 500;
  font-family: "Arial", sans-serif;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

/* オプション：ボタンレイアウト（横）*/
.button-container {
  display: flex; /* 横並びにする */
  gap: 1.5vw; /* ボタン間のスペース */
  justify-content: center; /* ボタンを中央に配置 */
  margin-bottom: 10px; /* 下に少し余白を追加 */
  margin-top: 0.7vw;
}

/* オプション：ボタンの共通スタイル */
.button-container button {
  font-family: "Arial", sans-serif;
  font-size: 1.7vw;
  padding: 3px 15px 3px 15px;
  margin: 0px 0px;
  border: none;
  border-radius: 105px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
  color: white;
}
/* オプション：サウンドテストボタン */
#openSoundTest  {
  background: linear-gradient(to bottom, #dfeef5, #38bdf8);
}
#openSoundTest:hover {
  transform: translateY(-3px);
  background: linear-gradient(to bottom, #dfeef5, #00b3ff);
}
/* オプション：アセット管理ボタン */
#asset-button  {
  background: linear-gradient(to bottom, #dfeef5, #f883f0);
}
#asset-button:hover {
  transform: translateY(-3px);
  background: linear-gradient(to bottom, #dfeef5, #ff01ee);
}
/* オプション：P2Pボタン */
#asset-drawer-list-p2p  {
  background: linear-gradient(to bottom, #dfeef5, #83f89c);
}
#asset-drawer-list-p2p:hover {
  transform: translateY(-3px);
  background: linear-gradient(to bottom, #dfeef5, #00ff37);
}
/* オプション：戻るボタン */
#option-back {
  font-size: 1.7vw;
  padding: 3px 10vw 3px 10vw;
  margin: 0px 0px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
  background: linear-gradient(to bottom, #dcdede, #363637); /* 明るい青系 */
  color: white;
}
#option-back:hover {
  transform: translateY(-3px);
  background: linear-gradient(to bottom, #d1d5db, #9ca3af);
}


/******************************************************************************/
/* ゲーム画面: 全体構成                                                         */
/******************************************************************************/
.game-screen {
  height: 100dvh; /* ← vhではなくdvh (ダイナミックビューポート) を使う */
  position: relative;
  width: 100%;
  overflow: hidden;
  z-index: 3;
}
.game-wrapper{
  background: #eee;
  min-height: 100vh;
  /*background-image: url(./../assets/img/game-bk.webp);*/
  position: relative;
  width: 100%;
  min-height: 100vh;     /* 画面縦を100%使用 */
  font-size: 3vw; /* 画面幅や親のサイズ基準に設定 */
  position: relative;
  /*background-image: url("../assets/img/title.png");*/
  width: 100%;
  /*aspect-ratio: 16 / 9;*/

  /* 縞々アニメーション */

  position: fixed;
  inset: 0;
  z-index: 0;
  background: repeating-linear-gradient(
    -45deg,
    #fff0f5,
    #fff0f5 10px,
    #ffe4e1 10px,
    #ffe4e1 20px
  );
  background-size: 200% 200%;
  animation: slideStripes 50s linear infinite;
}
/* 縞々アニメーション */
@keyframes slideStripes {
  from { background-position: 0 0; }
  to { background-position: 100% 100%; }
}

/* ゲーム画面: タイマー＆スコア表示 */
.game-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1em;
  font-size: clamp(14px, 3vw, 20px);
  font-weight: bold;
  color: #333;
}

/* ゲーム画面: カード配置エリア */
.card-area {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 7px;
  padding: 10px;
  overflow: auto;
  min-height: 100vh;     /* 画面縦を100%使用 */
  justify-content: center;   /* ← 横方向の中央揃え */
  align-content: center;     /* ← 縦方向の中央揃え */
  box-sizing: border-box;
  /*min-height: 100vh;     /* 画面縦を100%使用 */
  /*width: 100vh;     /* 画面縦を100%使用 */
  /*
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4列 *//*
  gap: 10px;
  justify-content: center;
  margin-bottom: 0em;
  padding: 0.5em;
  */
}
@media (max-width: 768px) {
  .card-area {
    grid-template-columns: repeat(var(--cols), auto);
    justify-content: center;
    gap: 10px; /* 隙間の調整も必要なら */
  }

  .card {
    width: 100px;  /* 画像サイズ固定で安定 */
  }
}
/* ゲーム画面: 戻るボタン */
#back-to-title {
  padding: 0.5em 1.5em;
  font-size: 1em;
  background: #999;
  color: white;
  border: none;
  border-radius: 10px;
}


/* 縦画面防止 */
#orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: white;
  color: black;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  text-align: center;
  padding: 2rem;
  line-height: 1.5;
  flex-direction: column;
}
@media screen and (orientation: portrait) and (max-width: 768px) {
  #game-screen { display: none !important; }
  #orientation-warning { display: flex !important; }
}

/* カード生成 */
.card {
  position: relative; /* ← これが無いとズレます */
  overflow: visible;
  aspect-ratio: 2 / 3;
  perspective: 1000px;
  max-height: 46vh;
}


.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.card-front {
  background: #eee;
  transform: rotateY(180deg); /* 表画像を180度回転（初期では見えない） */
}

.card-back {
  /*transform: rotateY(180deg);*/
   transform: rotateY(0deg); /* 裏画像が初期表示される */

}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* 🔄 切らずに収める */
  padding: 4px; /* 余白調整（必要に応じて） */
}

 /*  カード捲り処理： flipped の切り替えスタイルを追加*/
.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card.show-split .card-front {
  display: none;
}
.card.show-split .split-img {
  display: block;
}

/* 分割画像の反転を戻す；必須  */
.split-img {
  transform: scaleX(-1); /* ← 逆にして元に戻す */

  height: 100%;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.split-img img {
  object-fit: contain;
  height: auto;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
}
/* 結合アニメーション用 */
.merge-piece {
  position: absolute;
  transition: all 1s ease-in-out;
  opacity: 1;
}

/* ✅ 一致時：光る */
@keyframes glow {
  0% { box-shadow: 0 0 0px rgba(255, 255, 0, 0); }
  50% { box-shadow: 0 0 20px rgba(255, 255, 0, 0.9); transform: scale(1.1); }
  100% { box-shadow: 0 0 0px rgba(255, 255, 0, 0); transform: scale(1); }
}

.card.glow {
  animation: glow 2.6s ease-in-out;
}

/* ✅ 不一致時：震える */
@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

.card.shake {
  animation: shake 0.6s ease;
}



/* ラッキーカードエフェクト */
.lucky-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6em;
  font-weight: bold;
  color: rgb(255, 37, 9);
  text-align: center;
  white-space: pre-line;
  padding: 0.3em 0.8em;
  background: rgba(255, 223, 100, 0.6); /* 半透明の金色背景 */
  border-radius: 10px;
  box-shadow: 0 0 10px gold;
  animation: fadeUp 1s ease-out, shimmer 1.5s infinite;
  pointer-events: none;
  z-index: 10;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes shimmer {
  0%, 100% { box-shadow: 0 0 5px gold; }
  50% { box-shadow: 0 0 20px gold; }
}

/* タイマー、スコア(ヘッダー) フローティング風デザイン*/
.hud {
  position: absolute;  /* 固定位置に配置 */
  top: 1rem;
  text-align: left;
  right: 1rem;
  background-color: rgba(0, 0, 0, 0.4);  /* 半透明で邪魔しない */
  color: #fff;
  padding: 0.6em 1em;
  border-radius: 10px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column; /* 縦並び（横並びも可） */
  gap: 0.2em;
  z-index: 1000; /* 他のUIより前面に表示 */
  pointer-events: none; /* 追加 */
}



/* カードがそろった後のアニメーション処理 */
.full-image {
  max-width: 98vw;
  max-height: 98vh;
  width: auto;
  height: auto;
  margin: 0 auto;

  opacity: 0;
  transform: scale(0.9);
  animation: revealImage 0.6s ease-out forwards;

  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
}
@keyframes revealImage {
  to {
    opacity: 1;
    transform: scale(1);
  }
}



#game-screen-clearVideo {
  position: fixed;

  /*background: rgba(0, 0, 0, 0.6);*/
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
  text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.9); /* ←黒縁っぽく */

}
#clearVideo{
  width: 100vw;
  height: 100vh;

  margin: 0 auto;

  opacity: 0;
  transform: scale(0.9);
  animation: revealImage 0.6s ease-out forwards;

  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
}


/*<!-- ■ ステージクリアポップアップ -->*/
.popup {
  position: fixed;
  inset: 0;
  /*background: rgba(0, 0, 0, 0.6);*/
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.9); /* ←黒縁っぽく */
}
.popup-inner {
  position: relative;
  overflow: visible;
  /*background: white;*/
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0.3));
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
  width: clamp(250px, 50%, 600px);  /* ✅幅の下限/中間/上限を指定 */
  max-height: 80vh;                 /* ✅縦画面時にスクロール余地あり */
  /*overflow-y: auto;                 /* ✅縦に長くなった場合スクロール */
  animation: fadein 1.5s ease;
  color: white;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.7); /* ←黒縁っぽく */
}
@keyframes stamp3dDrop {
  0% {
    opacity: 0;
    transform: translateZ(300px) rotate(0deg) rotateX(-90deg) scale(0.3);
  }
  100% {
    transform: translateZ(0) rotate(25deg) rotateX(0deg) scale(1);
    opacity: 1;
  }
}

#clear-popup-stage{
  font-size: 2vw;
  text-shadow: 1px 2px 4px rgba(247, 179, 179, 0.9); /* ←黒縁っぽく */
}
#clear-popup-clear{
  font-size: 2vw;
  text-shadow: 1px 2px 4px rgba(247, 179, 179, 0.9); /* ←黒縁っぽく */
}


#rank-stamp.show {
  animation: stamp3dDrop 0.8s ease-out forwards;
}

/* スタンプ表示 */
#stamp-wrapper {
  position: absolute;
  top: 10px;
  right: 55px;
  width: 100px;
  height: 100px;
  z-index: 10;
  pointer-events: none; /* ボタンに干渉しないようにする */
}

#rank-stamp {
  z-index: 2; /* innerより上にする */
  position: absolute;
  width: 100%;
  transform-style: preserve-3d;
}
@keyframes stamp3dDrop {
  0% {
    opacity: 0;
    transform: translateZ(300px) rotate(0deg) rotateX(-90deg) scale(0.3);
  }
  100% {
    transform: translateZ(0) rotate(25deg) rotateX(0deg) scale(1);
    opacity: 0.9;
  }
}
#rank-stamp.show {
  animation: stamp3dDrop 0.8s ease-out forwards;
}

/* クリアー時のステージ番号 */
#stage-popup{
  color: rgb(249, 81, 157);
  text-shadow: 1px 2px 3px #000000;
  font-size: 2.5rem;
}
/* 次のステージへ */
#next-stage-btn {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border: none;
  border-radius: 1px;
  cursor: pointer;
  transition: background 0.2s;
  background: linear-gradient(to right, #1db0f4, #3165e0);
  color: white;
  border-radius: 10px;
  box-shadow: 2px 4px 8px rgba(0,0,0,0.9);
  transition: transform 0.2s, box-shadow 0.2s;
  text-shadow: 1px 2px 4px rgba(37, 2, 132, 0.9); /* ←黒縁っぽく */
}
#next-stage-btn:hover {
  box-shadow: 3px 6px 12px rgba(0,0,0,0.6);
  background: #225be1;
}

.hidden {
  display: none;
}
/* ボタンがふわっと浮かぶ */
.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease-out forwards;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



/*ゲームオーバー：カードアニメーション*/
#gameover-screen {
  position: relative;
  justify-content: center;
  align-items: center;
  z-index: 0;
  height: 100vh;
}
#gameover-text{
  position: absolute;
  z-index: 2;
  top: 50%;/*親の中央に「左上角」がくる*/
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #333;
  font-size: 1.5rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.5));
  padding: 1rem 4rem 1.5rem 4rem;
  border-radius: 10px;/*角丸*/
  text-align: center;
  /*width: 450px;*/
  /*width: clamp(550px, 60%, 700px);*/
  max-height: 80vh;
  animation: fadein 2.5s ease;
  color: white;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}
#game-over-title {
  font-size: 3rem;
  font-weight: 700;
  font-family: 'Cormorant Garamond', serif;
  color: white;
  text-align: center;
text-shadow:
  0 0 6px rgba(255, 255, 255, 0.6),
  0 0 12px rgba(255, 200, 250, 0.2);

  font-family: 'Zen Kurenaido', '游明朝', serif; /* 柔らかい和文フォント推奨 */
  letter-spacing: 0.1em;
}
#game-over-text-sub{
  font-family: 'Segoe UI', sans-serif;
  font-size: 1.2rem;
  color: #ddd;
  text-align: center;
  margin-bottom: 1.0rem;
  line-height: 1.0;
}
#gameover-btn{
  background-color: #7b2cbf; /* 落ち着いた紫 */
  color: white;
  font-size: 1rem;
  padding: 0.6rem 1.8rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#gameover-btn:hover {
  background-color: #9d4edd;
  transform: scale(1.05);
}

#gameover-card-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, 120px);
  grid-template-rows: repeat(3, 180px);
  gap: 10px;
}
.gameover-card {
  width: 120px;
  height: 180px;
  background-size: cover;
  border-radius: 12px;
  animation: burnAway 5.5s ease-out forwards;
}
@keyframes burnAway {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    transform: scale(1.2);
    filter: brightness(1.8) sepia(0.5);
  }
  100% {
    transform: scale(0.7) rotate(15deg);
    opacity: 0;
    filter: blur(4px) brightness(0.3);
  }
}



/* キャラクター用  */
#comment-character {
  position: absolute;
  bottom: 0;
  left: -500px; /* 初期は画面外 */
  display: flex;
  align-items: flex-end;
  transition: left 1s ease;
  z-index: 1000;
  pointer-events: none; /* ←クリックを通過させる */
  }
#comment-character.show {
  left: 10px; /* スライドイン位置 */
}
#comment-character img {
  height: 30vh;/*300px;*/
}
@media (max-width: 768px) {
  #comment-character img {
    height: 60vh; /* スマホならちょっと小さくする */
  }
}
.speech-bubble {
  display: none; /* 初期状態では非表示 */
  position: absolute;
  bottom: 80%; /* ← キャラの上に配置 */
  left: 130%;
  transform: translateX(-50%);
  background: white;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 16px;
  color: black;
  white-space: nowrap;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
  margin-bottom: 10px;
}


/* エンディング用：カードの降下アニメーション（CSS）*/
.end-card3d {
/*  width: 100px;
  height: 140px;
  top: -140px;*/
  position: absolute;
  perspective: 1200px;
  object-fit: contain; /* or contain */
  position: absolute;
}

.end-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: fallRotateY 10s ease-in forwards;
  transition: transform 0.7s;

}
.end-card3d.flipped .end-card-inner {
  transform: rotateY(180deg);
}
.end-card-front,
.end-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.end-card-front img,
.end-card-back img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* or contain */
  opacity: 0.7;
}
.end-card-back {
  transform: rotateY(180deg);
}

@keyframes fallRotateY {
  0% {
    transform: translateY(0) rotateY(180deg); /* 0deg */
  }
  100% {
    /*transform: translateY(150vh) rotateY(540deg);/* 360deg */
  }
}


/*  */
#ending-overlay {
  position: relative;
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

#bubbleCanvas, #card-layer, #endroll-text {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#credits-container {
  overflow: hidden;
  height: 100vh;
  position: relative;
}

#credits {
  position: absolute;
  width: 100%;
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 3.3vw;
  color: white;
  will-change: transform;
  text-shadow: 3px 4px 3px rgb(255, 73, 203);
}
#ending-title{
  font-size: 5.2vw;
  text-shadow: 3px 4px 3px rgb(0, 0, 0);
  display: block;
  padding-bottom: 0px;
  font-family: 'Orbitron', sans-serif;
}


#card-layer {
  position: absolute;
  z-index: 2; /* カードがその上に */
  overflow: hidden; /* ← 子要素がはみ出しても見えなくなる */
  object-fit: cover; /* ← これが特に重要 */
  display: flex;              /* 中央寄せにする */
  justify-content: center;    /* 横方向中央 */
  align-items: center;        /* 縦方向中央 */
}
#card-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* ← これが特に重要 */
  display: block;
}

#endroll-text {
  position: absolute;
  z-index: 3; /* テキストは一番手前に */
  background: rgba(0, 0, 0, 0.6); /* 薄暗い透明 */
}

/* ネクストステージ：背景をゆっくり暗転 */
#endroll-text.fade-to-black  {
  background-color: black !important;
  opacity: 1 !important; /* ← これ追加 */
  transition: background-color 5s ease;
}



.end3-card-flip {
  margin: 0 auto;
  width: 75%;
  aspect-ratio: 3 / 2;
  perspective: 1000px;
}

.end3-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 3s;
  color: white;
  will-change: transform;
  border-radius: 12px;
}

.end3-card-flip.flipped .end3-card-inner {
  transform: rotateX(180deg);
}
.end3-card-front {

}
.end3-card-front img {

  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  border-radius: 12px;
  animation: fadeIn 2s ease-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}



.end3-card-front,
.end3-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  pointer-events: auto;

}

.end3-card-back {
  transform: rotateX(180deg);
  background: rgba(250, 149, 149, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;

  flex-direction: column;
  font-size: 3.8vw;
  text-shadow: 3px 4px 3px rgb(255, 73, 203);
  opacity: 0;
  animation: fadeInText 2s ease-in 0.5s forwards;
}
@keyframes fadeInText {
  to {
    opacity: 1;
  }
}



#ending-screen{
    pointer-events: none;
}
#post-endroll-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 45%;
  border-radius: 10px;/*角丸*/
  background: linear-gradient(to bottom, rgba(70, 59, 59, 0.9), rgba(123, 115, 115, 0.8));
  font-family: 'Orbitron', sans-serif;
  font-size: 2vw;
  line-height: 2.0;
  /*pointer-events: none;*/

  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 100;
  color: white;
  opacity: 0;
  transition: opacity 1s ease;
  display: flex;
  flex-direction: column;
}

#post-endroll-message.show {
  /* display: block; ← これ削除！！ */
  opacity: 1;
}

.end-message {

  font-size: 10px;
  font-size: 3vw;
  text-shadow: 3px 4px 3px rgb(191, 162, 177);
  /*background-color: #000;*/

}
.end-message-sub {
  font-size: 3.2vw;
  color: #d3679d;
  text-shadow: 3px 4px 3px rgb(240, 15, 131);
  letter-spacing: 0.1em;
  padding-bottom: 20px;
}

.play-again-btn {
  font-size: 1rem;
  padding: 0.6em 1.5em;
  background-color: #ffffff22;
  color: white;
  border: 2px solid white;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}
.play-again-btn:hover {
  background-color: white;
  color: #333;
}





/* マウスオーバーした際のデザイン */

#return-to-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  padding: 0.6em 2em;
  background: linear-gradient(to bottom, #f78cb7, #ef5291);
  color: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 0 #b54b92, 0 6px 15px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
/*
  pointer-events: auto !important;*/
  z-index: 3;
}

#return-to-title:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #990066, 0 10px 20px rgba(0, 0, 0, 0.4);
}

#return-to-title:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #660033;
}

#return-to-title.show {
  opacity: 1;
  transform: translateY(0);
}
