/* リセットとベース設定 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Arial", sans-serif;
  background: url("img/bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ゲームコンテナ */
.game-container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 20px;
  max-width: 800px;
  width: 100%;
}

/* 難易度選択画面 */
.difficulty-select {
  text-align: center;
  padding: 40px 20px;
}

.difficulty-select h1 {
  color: #333;
  margin-bottom: 10px;
  font-size: 28px;
}

.difficulty-select h2 {
  color: #666;
  margin-bottom: 40px;
  font-size: 20px;
  font-weight: normal;
}

.difficulty-buttons {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-btn {
  position: relative;
  background: linear-gradient(145deg, #f0f0f0, #e0e0e0);
  border: 3px solid #ddd;
  border-radius: 15px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 150px;
  font-family: inherit;
  flex: 1;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.difficulty-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border-color: #4caf50;
}

.difficulty-btn.easy {
  background: linear-gradient(145deg, #e8f8ff, #d4edff);
  border-color: #2196f3;
}

.difficulty-btn.normal {
  background: linear-gradient(145deg, #e8f5e8, #d4edda);
  border-color: #4caf50;
}

.difficulty-btn.hard {
  background: linear-gradient(145deg, #ffe8e8, #ffd4d4);
  border-color: #ff6b6b;
}

.difficulty-btn.oni {
  background: linear-gradient(145deg, #f0e8ff, #e6d7ff);
  border-color: #9c7bf7;
}

.difficulty-btn.easy:hover {
  background: linear-gradient(145deg, #d4edff, #b8deff);
}

.difficulty-btn.normal:hover {
  background: linear-gradient(145deg, #d4edda, #c3e6cb);
}

.difficulty-btn.hard:hover {
  background: linear-gradient(145deg, #ffd4d4, #ffb8b8);
}

.difficulty-btn.oni:hover {
  background: linear-gradient(145deg, #e6d7ff, #d4c4ff);
}

/* 難易度選択の画像 */
.difficulty-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.difficulty-btn:hover .difficulty-image {
  transform: scale(1.1);
}

/* 最高スコア表示 */
.high-score {
  font-size: 14px;
  color: #666;
  font-weight: bold;
  margin-top: 5px;
}

/* ゲームヘッダー */
.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-header h1 {
  color: #333;
  margin-bottom: 10px;
  font-size: 24px;
}

.score-container {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  color: #666;
}

/* ゲームエリア */
.game-area {
  width: 100%;
  height: 400px;
  background: #87ceeb; /* 青空のみ */
  border: 3px solid #333;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

/* プレイヤー */
.player {
  width: 150px;
  height: 150px;
  background-image: url("img/hachiware.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  left: 50px;
  bottom: 0px; /* ashibaの真上 */
  transition: none;
  z-index: 10;
}

/* CSSアニメーションは無効化（JSアニメーションを使用） */
.player.jumping {
  /* animation: jump 0.8s ease-out; */
}

.player.jumping2 {
  /* animation: jump 0.8s ease-out; */
}

/* 
@keyframes jump {
  0% {
    bottom: 0px;
    animation-timing-function: ease-out;
  }
  30% {
    bottom: 156px;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  100% {
    bottom: 0px;
  }
}
*/

/* 地面 */
.ground {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  background-image: url("img/ashiba.png");
  background-size: cover;
  background-repeat: repeat-x;
  background-position: bottom;
  border-top: 3px solid #654321;
}

/* 障害物 */
.obstacle {
  width: 105px;
  height: 105px;
  background-image: url("img/sticker.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  bottom: 30px; /* さらに10px下げて配置 */
  right: -50px;
  z-index: 5;
  --move-duration: 2.5s; /* CSS変数でmoveObstacleの時間を制御 */
}

.obstacle.moving {
  animation: moveObstacle var(--move-duration) linear forwards;
}

@keyframes moveObstacle {
  from {
    right: -50px;
  }
  to {
    right: 100%;
  }
}

/* ジャンプ予告の震えアニメーション */
.obstacle.shaking {
  animation: moveObstacle var(--move-duration) linear forwards,
    obstacleShake 0.15s ease-in-out infinite;
}

/* 飛び越える障害物のジャンプアニメーション */
.obstacle.jumping {
  animation: moveObstacle var(--move-duration) linear forwards,
    obstacleJump 0.8s ease-in-out;
}

@keyframes obstacleShake {
  0% {
    transform: translateX(0px);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-3px);
  }
  100% {
    transform: translateX(0px);
  }
}

@keyframes obstacleJump {
  0% {
    bottom: 30px;
  }
  50% {
    bottom: 200px; /* 30px + 170px（ジャンプ高度調整）*/
  }
  100% {
    bottom: 30px;
  }
}

/* コントロール */
.game-controls {
  text-align: center;
  margin-bottom: 20px;
}

.game-controls p {
  margin-bottom: 15px;
  font-size: 18px;
  color: #333;
}

/* 操作方法表示 */
.controls-info {
  margin-top: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 15px;
  border: 2px solid #e9ecef;
}

.controls-info h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 20px;
}

.controls-info p {
  margin-bottom: 8px;
  font-size: 16px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.controls-display {
  margin-bottom: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.controls-display p {
  margin-bottom: 5px;
  font-size: 16px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ライフ表示（オーバーレイ） */
.life-container-overlay {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none; /* マウスイベントを通す */
}

.life-display {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 12px;
  border-radius: 20px;
  backdrop-filter: blur(5px);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.life-heart {
  width: 28px;
  height: 28px;
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.life-heart.damaged {
  opacity: 0.3;
  filter: grayscale(100%) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* 音量コントロール */
.volume-control {
  margin-top: 20px;
  padding: 20px;
  background: #f0f8ff;
  border-radius: 15px;
  border: 2px solid #d0e8ff;
}

.volume-control h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 18px;
  text-align: center;
}

.volume-slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  justify-content: center;
}

.volume-slider-container label {
  font-size: 14px;
  color: #555;
  min-width: 60px;
}

.volume-slider {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4caf50;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4caf50;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.volume-slider-container span {
  font-size: 12px;
  color: #666;
  min-width: 35px;
  text-align: right;
}

/* 難易度解放システム */
.difficulty-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.difficulty-btn.locked::before {
  content: "🔒";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  z-index: 5;
}

.unlock-condition {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #999;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.difficulty-btn:not(.locked) .unlock-condition {
  display: none;
}

/* 目標スコア表示 */
.target-score {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #d32f2f;
  background: linear-gradient(135deg, #ff6b6b, #ff5252);
  padding: 4px 12px;
  border-radius: 15px;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(255, 82, 82, 0.4);
  border: 2px solid #fff;
  z-index: 10;
  color: white;
}

/* かんたん難易度専用の青色バージョン */
.easy .target-score {
  background: linear-gradient(135deg, #2196f3, #42a5f5);
  box-shadow: 0 3px 12px rgba(33, 150, 243, 0.4);
  color: white;
}

/* ふつう難易度専用の緑色バージョン */
.normal .target-score {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  box-shadow: 0 3px 12px rgba(76, 175, 80, 0.4);
  color: white;
}

/* おに難易度専用の紫色バージョン */
.oni .target-score {
  background: linear-gradient(135deg, #a855f7, #8b5cf6);
  box-shadow: 0 3px 12px rgba(168, 85, 247, 0.4);
  color: white;
}

.difficulty-btn.locked:hover {
  transform: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ミュートボタン */
.mute-controls {
  margin-top: 15px;
  text-align: center;
}

.mute-btn {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mute-btn:hover {
  background: #ff5252;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.mute-btn:active {
  transform: translateY(0);
}

/* リセットボタンセクション */
.reset-section {
  margin-top: 15px;
  text-align: center;
  padding: 10px 15px 10px 15px;
  border-top: 2px solid #e9ecef;
}

/* 星とパリィエフェクト（おに難易度専用） */
.star {
  pointer-events: none;
}

.parry-effect {
  pointer-events: none;
}

@keyframes parryEffect {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.reset-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 3px 6px rgba(220, 53, 69, 0.3);
}

.reset-btn:hover {
  background: #c82333;
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(220, 53, 69, 0.4);
}

.reset-btn:active {
  transform: translateY(0);
}

.start-btn,
.restart-btn,
.play-again-btn {
  background: #4caf50;
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 25px;
  cursor: pointer;
  transition: background 0.3s;
}

.start-btn:hover,
.restart-btn:hover,
.play-again-btn:hover {
  background: #45a049;
}

.restart-btn {
  background: #ff9800;
}

.restart-btn:hover {
  background: #e68900;
}

.back-menu-btn {
  background: #2196f3; /* もう一度プレイと同じ濃さの青色 */
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 25px; /* 丸みを帯びたレイアウト */
  cursor: pointer;
  transition: background 0.3s;
  font-family: inherit;
  margin-left: 10px;
  font-weight: normal;
}

.back-menu-btn:hover {
  background: #1976d2; /* ホバー時は少し濃い青 */
}

/* ゲームオーバー画面 */
.game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.game-over h2 {
  color: #ff4444;
  font-size: 48px;
  margin-bottom: 20px;
  animation: pulse 1s infinite;
}

.game-over p {
  color: white;
  font-size: 24px;
  margin-bottom: 30px;
}

.game-over .back-menu-btn {
  margin-left: 0;
  margin-top: 10px;
}

/* ゲームクリア画面 */
.game-clear {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    45deg,
    rgba(255, 215, 0, 0.9),
    rgba(255, 165, 0, 0.9)
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.clear-content {
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: clearAppear 0.8s ease-out;
}

.clear-image {
  width: 200px;
  height: auto;
  margin-bottom: 20px;
  animation: clearImageFloat 2s ease-in-out infinite;
}

.game-clear h2 {
  color: #ff6600;
  font-size: 48px;
  margin-bottom: 20px;
  animation: clearPulse 1.5s infinite;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.clear-message {
  color: #333;
  font-size: 20px;
  margin-bottom: 15px;
  font-weight: bold;
}

.game-clear p {
  color: #666;
  font-size: 18px;
  margin-bottom: 30px;
}

.game-clear .back-menu-btn {
  margin-left: 0;
  margin-top: 10px;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes clearPulse {
  0% {
    transform: scale(1);
    color: #ff6600;
  }
  50% {
    transform: scale(1.05);
    color: #ff8800;
  }
  100% {
    transform: scale(1);
    color: #ff6600;
  }
}

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

@keyframes clearImageFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* パリィ操作説明のハイライト */
.parry-control-highlight {
  background: linear-gradient(135deg, #8b5cf6, #a855f7);
  color: white !important;
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid #fff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  animation: parryGlow 2s ease-in-out infinite;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes parryGlow {
  0%,
  100% {
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  }
  50% {
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.6);
  }
}

/* ゲーム解放画面 */
.game-unlock {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    45deg,
    rgba(138, 43, 226, 0.9),
    rgba(75, 0, 130, 0.9)
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.unlock-content {
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: unlockAppear 1s ease-out;
}

.unlock-image {
  width: 200px;
  height: auto;
  margin-bottom: 20px;
  animation: unlockImageFloat 2.5s ease-in-out infinite;
}

.game-unlock h2 {
  color: #8b2aa3;
  font-size: 48px;
  margin-bottom: 20px;
  animation: unlockPulse 2s infinite;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.unlock-message {
  color: #333;
  font-size: 20px;
  margin-bottom: 15px;
  font-weight: bold;
}

.game-unlock p {
  color: #666;
  font-size: 18px;
  margin-bottom: 30px;
}

.game-unlock .back-menu-btn {
  margin-left: 0;
  margin-top: 10px;
}

@keyframes unlockPulse {
  0% {
    transform: scale(1);
    color: #8b2aa3;
  }
  50% {
    transform: scale(1.08);
    color: #a855f7;
  }
  100% {
    transform: scale(1);
    color: #8b2aa3;
  }
}

@keyframes unlockAppear {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(-80px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes unlockImageFloat {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-8px) rotate(2deg);
  }
  66% {
    transform: translateY(-4px) rotate(-2deg);
  }
}

/* 各難易度のクリア画面 */
.difficulty-clear {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.easy-clear {
  background: linear-gradient(
    45deg,
    rgba(76, 175, 80, 0.9),
    rgba(139, 195, 74, 0.9)
  );
}

.normal-clear {
  background: linear-gradient(
    45deg,
    rgba(33, 150, 243, 0.9),
    rgba(3, 169, 244, 0.9)
  );
}

.hard-clear {
  background: linear-gradient(
    45deg,
    rgba(244, 67, 54, 0.9),
    rgba(255, 87, 34, 0.9)
  );
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
  .game-container {
    margin: 10px;
    padding: 15px;
  }

  .game-area {
    height: 300px;
  }

  .game-header h1 {
    font-size: 20px;
  }

  .score-container {
    font-size: 14px;
  }
}
