/* すべての要素に対してボックスサイズをborder-boxに設定（paddingやborderを含めたサイズ計算） */
* {
  box-sizing: border-box;
  /* モバイルでタップ時のハイライトを無効化 */
  -webkit-tap-highlight-color: transparent;
}

/* html全体の余白と高さをリセット */
html {
  margin: 0;
  height: 100%;
}

/* bodyの基本レイアウト設定（中央配置） */
body {
  margin: 0;
  height: 100vh;
  font-family: sans-serif;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ゲーム全体のコンテナ */
.container {
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  /* 背景画像設定 */
  background-image: url("assets/bg.png");
  background-size: cover;
  background-position: center;
  /* テキスト選択を無効化 */
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  position: relative;
}

/* 半透明の白オーバーレイ */
.container::before {
  content: "";
  position: absolute;
  inset: 0;

  background: rgba(255, 255, 255, 0.25);

  z-index: 0;
}

/* ヘッダー部分 */
.game-header {
  height: 50px;
  padding: 4px 14px;
  flex: 0 0 50px;
  display: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;

  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  border-bottom: 2px solid rgba(0,0,0,0.1);
  border-radius: 0 0 12px 12px;
}

/* ヘッダー左側（余白用） */
.header-left {
  min-width: 1px;
}

/* ヘッダー中央（メッセージ） */
.header-center {
  text-align: center;
  line-height: 1.1;
}

/* ヘッダーとメインを前面に表示 */
.game-header,
.game-main {
  position: relative;
  z-index: 1;
}

/* ターゲットメッセージ */
.target-message {
  margin: 0;
  font-size: 22px;
  font-weight: bold;
  color: #1b5e20;
}

/* 残り時間メッセージ */
.remain-message {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: bold;
  color: #e65100;
}

/* 右側スコア表示 */
.header-right {
  justify-self: end;
  font-size: 18px;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
}

/* ゲームメインエリア */
.game-main {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
}

/* ボタン共通スタイル */
.btn {
  padding: 18px 40px;
  font-size: 24px;
  font-weight: bold;
  border: none;
  border-radius: 999px;
  background: #18c56e;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px #0e9f56;
  transition: all 0.15s ease;
  z-index: 20;
}

/* ホバー時の色変化 */
.btn:hover {
  background: #1edc7c;
}

/* クリック時の押し込み表現 */
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px #0e9f56;
}

/* ゲーム表示パネル */
.game-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

/* 虫のスタイル */
.bug {
  position: absolute;
  cursor: pointer;
  user-select: none;
  z-index: 10;
}

/* 正解時の円エフェクト */
.correct-circle {
  position: absolute;
  border: 8px solid #ff5252;
  border-radius: 50%;
  width: 90px;
  height: 90px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 50;
  animation: circle-out 0.5s ease-out forwards;
}

/* 円が広がるアニメーション */
@keyframes circle-out {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
  }
}

/* ミス時の揺れエフェクト */
.shake {
  animation: shake-anim 0.3s ease-in-out;
}

/* 揺れアニメーション定義 */
@keyframes shake-anim {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-8px, 0);
  }
  75% {
    transform: translate(8px, 0);
  }
}

/* 結果表示画面 */
.result {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
}

/* 結果タイトル */
.result-title {
  margin: 0;
  font-size: 40px;
  color: #ffeb3b;
}

/* 結果テキスト */
.result-text {
  margin: 0;
  font-size: 30px;
  font-weight: bold;
  color: #ffffff;
}

/* 新記録表示 */
.new-record {
  margin: 0;
  font-size: 26px;
  font-weight: bold;
  color: #ffeb3b;
}

/* レスポンシブ対応（画面幅900px以下） */
@media (max-width: 900px) {
  /* ターゲット文字サイズ */
  .target-message {
    font-size: 18px;
  }

  /* 残り時間文字サイズ */
  .remain-message {
    font-size: 14px;
  }

  /* スコア文字サイズ */
  .header-right {
    font-size: 14px;
  }

  /* 虫サイズ調整 */
  .bug {
    width: 60px;
    height: 60px;
  }
}