body {
  margin: 0;
  background-image: url('image/common/bg.jpg');
  justify-content: center;
  font-family: sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.game-container {
  width: 768px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: 20px;
  border: #210 solid 5px;
}

/* 1段目 */
.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  font-size: 24px;
  color: #fff;
  background: #210;
  box-sizing: border-box;
}

.char-btn {
  background: #444;
  color: #fff;
  font-size: 18px;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 4px;
}

/* 2段目 */
.game-area {
  width: 768px;
  height: 1152px;
  background: no-repeat center/cover;
  position: relative;
}


.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100%;
  height: 100%;
  perspective: 1200px;
}

/* --- カード構造 --- */
.cell {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  cursor: pointer;
  -webkit-user-select: none;  /* iOS Safari, Chrome, Edge 対応 */
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* iOS 長押しのメニュー抑制 */
}

.cell-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.cell-front, .cell-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background-size: cover;
  background-position: center;
  border: none;
  /* border: 1px solid rgba(255,255,255,0.05); */
}

/* 表面（開いた後） */
.cell-front {
  transform: rotateY(180deg);
}

/* 裏面（開く前） */
.cell-back {
  transform: rotateY(0deg);
}

/* めくりアニメ */
.cell.open .cell-inner {
  transform: rotateY(180deg);
}

/* 揃ったセルを非表示（背景を透かす） */
.cell.matched {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

/* ミス時の揺れ演出 */
.cell.wrong {
  animation: shake 0.4s;
}
@keyframes shake {
  0%,100% { transform: rotate(0deg); }
  25% { transform: rotate(3deg); }
  75% { transform: rotate(-3deg); }
}

/* 3段目 */
.life-bar {
  width: 100%;
  padding: 10px;
  display: flex;
  justify-content: flex-end;
  background: #210;
  box-sizing: border-box;
}
.life-bar img {
  width: 50px;
  height: 50px;
  margin-right: 5px;
  transition: opacity 0.3s, transform 0.3s;
}
.life-bar img.lost {
  opacity: 0.3;
  transform: scale(0.4);
}

/* クリア演出 */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
  text-shadow: 0 0 20px #ff0;
}
.overlay.show {
  opacity: 1;
  animation: flash 1.2s infinite alternate;
}
@keyframes flash {
  0% { text-shadow: 0 0 10px #fff; }
  100% { text-shadow: 0 0 40px #ff0; }
}

#gameover-screen {
  width: 805px;
  height: 1320px;
  background-image: url('image/dark-mosaic.png'); /* ローコントラストの模様 */
  background-color: #200;
  background-blend-mode: overlay;
  background-size: cover;
  position: absolute;
  display: none;
  overflow: hidden;
  margin: auto;
  z-index: 8888;
}

#newgame-screen {
  width: 795px;
  height: 1310px;
  background-image: url('image/common/start_bg.jpg');
  background-color: #99ccff;
  background-blend-mode: overlay;
  background-size: cover;
  position: absolute;
  display: block;
  overflow: hidden;
  margin: auto;
  z-index: 7777;
  border: #b02 solid 5px;
}

#gameover-logo {
  position: absolute;
  top: -600px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
}

#newgame-logo {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
}

.bounce {
  animation: bounce 1s ease forwards;
}

@keyframes bounce {
  0%   { top: -600px; }
  70%  { top: 100px; }
  85%  { top: 40px; }
  100% { top: 100px; }
}

.gameover-button {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 1s ease;
  width: 500px;
  padding: 40px;
  background: linear-gradient(to bottom, #ff3333, #990000);
  text-align: center;
  font-size: 36px;
  color: white;
  border-radius:210px;
  font-family: sans-serif;
}

#gameover-continue {
  top: 650px;
}

#gameover-home {
  top: 900px;
  opacity: 0;
}

.newgame-button {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 100;
  transition: opacity 1s ease;
  width: 500px;
  padding: 40px;
  background: linear-gradient(to bottom, #ff6666, #cc0033);
  text-align: center;
  font-size: 36px;
  color: white;
  border-radius:210px;
  font-family: sans-serif;
}

#newgame-continue {
  top: 870px;
  display: none;
}

#newgame-txt {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 100;
  transition: opacity 1s ease;
  width: 700px;
  padding: 40px;
  text-align: center;
  font-size: 28px;
  color: black;
  font-family: sans-serif;
  top: 970px;
  display: none;
}

#newgame-home {
  top: 650px;
}


    #ad-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.95);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9999;
    }

    #ad-container {
      width: 800px;
      height: 1200px;
      background-color: black;
      position: relative;
    }

    #ad-message {
      color: white;
      text-align: center;
      font-size: 24px;
    }
	
    #ad-message2 {
      color: white;
      text-align: center;
      font-size: 24px;
    }

    /* 既存の ad-overlay に合わせた新クラス */
    #outstream-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.95);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9999;
    }

    #outstream-container {
      width: 800px;
      height: 1200px;
      background-color: black;
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }

    #outstream-message,
    #outstream-message2 {
      color: white;
      text-align: center;
      font-size: 24px;
      padding: 10px;
    }

    #outstream-ad-slot {
      flex-grow: 1;
    }
