body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    #87ceeb 0%,
    #98fb98 30%,
    #90ee90 70%,
    #f0e68c 100%
  );
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(
      circle at 20% 80%,
      rgba(120, 180, 83, 0.3) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(255, 182, 193, 0.2) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(173, 216, 230, 0.2) 0%,
      transparent 50%
    );
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M20 20c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10zm10 0c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 60px 60px, 40px 40px;
  background-position: 0 0, 20px 20px;
  animation: backgroundFloat 20s ease-in-out infinite;
  z-index: -1;
}

@keyframes backgroundFloat {
  0%,
  100% {
    transform: translateY(0px) translateX(0px);
  }
  25% {
    transform: translateY(-10px) translateX(5px);
  }
  50% {
    transform: translateY(-5px) translateX(-5px);
  }
  75% {
    transform: translateY(-15px) translateX(3px);
  }
}

/* ゲームモード時のレイアウト調整 */
body.game-mode {
  padding: 20px;
  justify-content: flex-start;
}

/* ゲームボード　サイズ指定は各デバイスの@media設定で決定 */
#game-board {
  position: relative;
  margin-bottom: 20px;
  border: 3px solid #8b4513;
  border-radius: 15px;
  background: linear-gradient(145deg, #f5deb3 0%, #deb887 50%, #d2b48c 100%);
  box-shadow: inset 0 0 20px rgba(139, 69, 19, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.3), 0 0 0 5px rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.tile {
  position: absolute;
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 50%, #e9ecef 100%);
  border: 2px solid #dee2e6;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: 1;
}

.tile:hover:not(.locked) {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border-color: #4caf50;
}

.tile.locked {
  background: #e0e0e0 !important;
  cursor: not-allowed;
  filter: grayscale(80%) brightness(0.7);
  border-color: #999 !important;
}

.tile.hint-highlight {
  border: 3px solid #4caf50;
  box-shadow: 0 0 15px #4caf50;
}

/* アニメーション用のクラス */
.tile.removing {
  animation: tileRemoveAnimation 0.6s ease-out forwards;
}

@keyframes tileRemoveAnimation {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
  }
  25% {
    transform: scale(1.2) rotate(15deg);
    opacity: 0.8;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    border: 2px solid #4caf50;
  }
  50% {
    transform: scale(1.3) rotate(-10deg);
    opacity: 0.6;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.8);
    background-color: #e8f5e8;
  }
  75% {
    transform: scale(0.8) rotate(5deg);
    opacity: 0.3;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
  }
  100% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
    box-shadow: none;
  }
}

/* パーティクルエフェクト */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background-color: #4caf50;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
}

.particle.star {
  background-color: #ffd700;
  font-size: 12px;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.particle.star::before {
  content: "★";
}

@keyframes particleAnimation {
  0% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(0.5) translateY(-50px);
    opacity: 0;
  }
}

/* マッチした時のフラッシュエフェクト */
.match-flash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(76, 175, 80, 0.3),
    rgba(255, 215, 0, 0.3)
  );
  border-radius: 5px;
  animation: flashEffect 0.5s ease-out;
  pointer-events: none;
  z-index: 999;
}

@keyframes flashEffect {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

.header {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 20px 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header-logo {
  max-width: 280px;
  max-height: 80px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.header h1 {
  margin: 0;
  color: #2e7d32;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  font-size: 2.2em;
  background: linear-gradient(45deg, #4caf50, #2e7d32);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.level-display,
.coin-display {
  font-size: 18px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 15px;
  color: #2e7d32;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#slot {
  border: 3px solid #8b4513;
  background: linear-gradient(145deg, #fff8dc 0%, #f5deb3 100%);
  border-radius: 15px;
  box-shadow: inset 0 2px 4px rgba(139, 69, 19, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15);
}


#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 25px;
  width: 100%;
}

.control-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.stage-select-group {
  display: flex;
  justify-content: center;
  gap: 15px;
}

button {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 25px;
  border: none;
  background: linear-gradient(145deg, #4caf50 0%, #45a049 100%);
  color: white;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  margin: 0 5px;
  position: relative;
  min-height: 48px;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  background: linear-gradient(145deg, #66bb6a 0%, #4caf50 100%);
}

button:active:not(:disabled) {
  transform: translateY(0px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

button:disabled {
  background: linear-gradient(145deg, #e0e0e0 0%, #bdbdbd 100%);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.cost {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  display: block;
  margin-top: 2px;
}

#stage-select-btn {
  background: linear-gradient(145deg, #2196f3 0%, #1976d2 100%);
  color: white;
  padding: 14px 35px;
  font-size: 16px;
}

#stage-select-btn:hover {
  background: linear-gradient(145deg, #42a5f5 0%, #2196f3 100%);
}

#ranking-btn {
  background: linear-gradient(145deg, #ff9800 0%, #f57c00 100%);
  color: white;
  padding: 14px 35px;
  font-size: 16px;
}

#ranking-btn:hover {
  background: linear-gradient(145deg, #ffb74d 0%, #ff9800 100%);
}

/* ステージクリアアニメーション */
.stage-clear-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.9) 0%,
    rgba(255, 165, 0, 0.9) 25%,
    rgba(255, 69, 0, 0.9) 50%,
    rgba(255, 140, 0, 0.9) 75%,
    rgba(255, 215, 0, 0.9) 100%
  );
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.5s ease-out;
}

.stage-clear-overlay.show {
  opacity: 1;
  transform: scale(1);
}

.stage-clear-overlay.fade-out {
  opacity: 0;
  transform: scale(1.1);
}

.stage-clear-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-align: center;
  position: relative;
  min-height: 400px;
}

.stage-image {
  width: 280px;
  height: auto;
  animation: stageImageAnimation 3s ease-in-out;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
  position: relative;
  z-index: 2;
}

.level-text {
  font-size: 64px;
  font-weight: bold;
  color: #fff;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8), 0 0 15px rgba(255, 255, 255, 0.6),
    0 0 30px rgba(255, 215, 0, 0.4);
  animation: levelTextAnimation 3s ease-in-out;
  z-index: 3;
  margin: -15px 0;
  line-height: 1;
}
