* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #222;
  font-family: system-ui, -apple-system, BlinkMacSystemFont;
}

header {
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid #333;
}

#logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.site-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  font-size: 20px;
  white-space: nowrap;
}

.left {
  display: flex;
  align-items: center;
}

header .center button {
  font-size: 28px;
  margin: 0 4px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
}

header button:disabled {
  opacity: 0.3;
}

main {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

#field {
  /* 画面幅に合わせてリサイズ（モバイル対応） */
  width: min(600px, 92vw);
  height: min(600px, 92vw);
  background: #8bc34a;
  border-radius: min(24px, 3.8vw);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: min(24px, 3.8vw);
  padding: min(24px, 3.8vw);
}

.hole {
  background: radial-gradient(circle at center, #9b6b52, #6d4c41);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}

.mole {
  /* 穴のサイズに対して相対的にリサイズ（モバイル対応） */
  width: min(128px, 76%);
  height: min(128px, 76%);
  border: 0;
  padding: 0;
  background: url("80_80.png") no-repeat center / contain;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 120%);
  transition: transform 0.15s ease;
  cursor: pointer;
  /* iOS タップ残像・フォーカス枠を消す */
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  outline: none;
  /* タップ遅延を排除 */
  touch-action: manipulation;
}

.mole:focus {
  outline: none;
}

.mole.show {
  transform: translate(-50%, -50%);
}

/* ヒット時は穴に戻るアニメーション（スケール縮小ではなく slide down） */
.mole.hit {
  transform: translate(-50%, 120%);
}

#startOverlay,
#resultOverlay,
#newHighScoreOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

#newHighScoreOverlay {
  overflow: hidden;
}

/* 落下エフェクト */
@keyframes fall {
  0%   { transform: translateY(0)     rotate(0deg);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg);  opacity: 0.4; }
}

.falling-mole {
  position: absolute;
  top: -72px;
  width: 64px;
  height: 64px;
  object-fit: contain;
  animation: fall linear forwards;
  pointer-events: none;
  z-index: 2;
}

/* 落下画像（z-index:2）の後ろにモーダルを配置 */
#newHighScoreOverlay .modal {
  position: relative;
  z-index: 1;
}

.modal--highscore {
  background: linear-gradient(160deg, #fff9c4 0%, #ffd600 55%, #ff8f00 100%);
  border-color: #e65100;
}

.hs-label {
  font-size: 48px;
  font-weight: 900;
  color: #bf360c;
  margin: 0 0 8px;
}

.hs-score {
  font-size: 88px;
  font-weight: 900;
  color: #b71c1c;
  line-height: 1;
  margin: 0 0 12px;
}

.hs-congrats {
  font-size: 40px;
  margin: 0;
}

.hidden {
  display: none !important;
}

.modal {
  background: linear-gradient(160deg, #fff39a 0%, #ffd9f1 55%, #d7f6ff 100%);
  padding: 40px;
  border-radius: 20px;
  border: 4px solid #ff9d00;
  text-align: center;
  min-width: 320px;
}

.modal button {
  margin-top: 16px;
  font-size: 22px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 240px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.modal h1 {
  font-size: 44px;
  margin: 0 0 14px;
  color: #ff3f6a;
}

.modal h2 {
  font-size: 56px;
  margin: 0 0 14px;
  color: #ff3f6a;
}

.modal p {
  font-size: 34px;
  margin: 0 0 8px;
  color: #1847b8;
  font-weight: 700;
}

#finalScore {
  font-size: 54px;
  color: #ff6a00;
}

/* スタートモーダルの遊び方 */
.how-to-play {
  font-size: 18px !important;
  color: #444 !important;
  font-weight: 500 !important;
  line-height: 1.7;
  margin: 0 0 14px !important;
}

/* スタートモーダルのハイスコア：やや控えめなサイズ */
#startHighScore {
  font-size: 20px;
  color: #777;
  font-weight: 600;
  margin: -6px 0 12px;
}

/* リザルトモーダルのハイスコア */
.result-highscore {
  font-size: 22px !important;
  color: #888 !important;
  font-weight: 600 !important;
  margin-top: 0 !important;
}

#resultHighScore {
  color: #ff6a00;
  font-size: 28px;
}

.linkBtn {
  display: block;
  margin: 16px auto 0;
  font-size: 22px;
  font-weight: 700;
  padding: 12px 24px;
  color: #fff;
  background: #333;
  border-radius: 10px;
  text-decoration: none;
  width: 240px;
}

#startBtn {
  background: #ff7a00;
}

#retryBtn {
  background: #19a64a;
}

.modal #clearHighScoreBtn {
  background: #999;
  font-size: 18px;
  padding: 12px 24px;
  width: 240px;
  margin-top: 6px;
  margin-bottom: 6px;
}
