* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Arial', sans-serif;
  background-color: #f0f8ff;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.game-container {
  text-align: center;
}

h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #ff4500;
}

.score {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(6, 60px);
  grid-gap: 5px;
  justify-content: center;
  position: relative;
  width: calc(60px * 6 + 5px * 5); /* 6 cells + gaps */
  height: calc(60px * 6 + 5px * 5);
}

.cell {
  width: 60px;
  height: 60px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  transition: transform 0.4s ease, background-color 0.3s ease;
  border: 2px solid #ffffff;
  border-radius: 10px;
}

/* Dragging animation */
.cell.dragging {
  opacity: 0.7;
  transform: scale(1.05);  /* A bit of a slower, calm scale transformation */
  transition: transform 0.4s ease;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
    opacity: 0.8;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.cell.pop {
  animation: pop 0.5s forwards;
}

@keyframes fall {
  from {
    transform: translateY(-70px); /* Falling from 70px above */
  }
  to {
    transform: translateY(0);
  }
}

.cell.new {
  animation: fall 0.5s ease forwards;
}

button {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1rem;
  color: white;
  background-color: #ff4500;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #ff6347;
}

.cell.highlight {
  animation: highlight 0.5s ease-in-out;
}

@keyframes highlight {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px 5px rgba(255, 255, 0, 0.7);
  }
  100% {
    transform: scale(1.2);
    box-shadow: 0 0 10px 5px rgba(255, 255, 0, 0);
  }
}

.cell.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.cell.new {
  animation: fall 0.5s ease forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(0);
  }
}

.highlight {
  border: 3px solid red; /* 赤枠で強調表示 */
  animation: highlight-animation 1s ease-in-out infinite;
}

@keyframes highlight-animation {
  0% { background-color: rgba(255, 0, 0, 0.3); }
  50% { background-color: rgba(255, 255, 0, 0.3); }
  100% { background-color: rgba(255, 0, 0, 0.3); }
}

.debug-flag {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 12px;
  color: black;
  background-color: rgba(255, 255, 255, 0.7);
  padding: 2px;
  border-radius: 3px;
  z-index: 10; /* フラグを画像より前面に表示 */
}

/* ツムが下に移動するアニメーション */
/* ツムが下に移動するアニメーション */
@keyframes moveDownAnimation {
  0% {
    transform: translateY(-100px); /* 上から移動してくる */
    opacity: 0; /* 最初は透明 */
  }
  50% {
    opacity: 1; /* 半分進んだところで透明度を元に戻す */
    transform: translateY(30px); /* 少し進んだ位置 */
  }
  100% {
    opacity: 1; /* 最終的に完全に表示 */
    transform: translateY(0); /* 元の位置に戻る */
  }
}

.cell.moving-down {
  animation: moveDownAnimation 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards; /* よりスムーズなタイミング */
}

@keyframes fairyBounce {
  0% {
    transform: translateY(-10px) scale(1.1);
    opacity: 0.8;
  }
  50% {
    transform: translateY(5px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.8;
  }
}

.cell.fairy-bounce {
  animation: fairyBounce 1s ease-in-out forwards;
}

@keyframes rainbowGlow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px 5px rgba(255, 0, 0, 1);  /* 赤 */
  }
  14% {
    box-shadow: 0 0 10px 5px rgba(255, 165, 0, 1);  /* オレンジ */
  }
  28% {
    box-shadow: 0 0 10px 5px rgba(255, 255, 0, 1);  /* 黄 */
  }
  42% {
    box-shadow: 0 0 10px 5px rgba(0, 255, 0, 1);  /* 緑 */
  }
  57% {
    box-shadow: 0 0 10px 5px rgba(0, 0, 255, 1);  /* 青 */
  }
  71% {
    box-shadow: 0 0 10px 5px rgba(75, 0, 130, 1);  /* 紫 */
  }
  85% {
    box-shadow: 0 0 10px 5px rgba(238, 130, 238, 1);  /* 薄紫 */
  }
  100% {
    transform: scale(0);  /* 消える */
    opacity: 0;
    box-shadow: none;
  }
}

.cell.rainbow-glow {
  animation: rainbowGlow 1s ease-out forwards;
}

/* 移動アニメーション */
@keyframes moveAnimation {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.move-animation {
  animation: moveAnimation 0.5s ease-in-out;
}
