.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;

  background-image: url("images/grass.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.hammer {
  position: fixed;
  width: 80px;
  pointer-events: none;
  transform: rotate(0deg);
  transition: transform 0.08s;
  z-index: 999;
}

.hammer.hit {
  transform: rotate(-35deg);
}

#title-screen,
#story-screen,
#game-screen {
  min-height: 100vh;
}

#game-screen {
  position: relative;
  cursor: none;
}

.game-hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;

  display: flex;
  gap: 20px;
}

.hud-item {
  margin: 0;
  padding: 10px 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

#score {
  color: #ffd700;
  font-size: 24px;
}

#time {
  color: #7ee787;
  font-size: 24px;
}

#time-item.time-low {
  background: rgba(180, 0, 0, 0.7);
  animation: time-low-pulse 0.6s ease-in-out infinite alternate;
}

#time-item.time-low #time {
  color: #ff5c5c;
}

@keyframes time-low-pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.08);
  }
}

@media (max-width: 600px) {
  .game-hud {
    top: 10px;
    gap: 10px;
  }

  .hud-item {
    padding: 8px 14px;
    font-size: 16px;
  }

  #score,
  #time {
    font-size: 18px;
  }
}

.game-board {
  display: grid;
  grid-template-columns: repeat(3, 150px);
  gap: 20px;
  width: max-content;
  margin: 50px auto;
}

.hole {
  width: 150px;
  height: 150px;
  background-image: url("images/hole.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: relative;
}

@media (max-width: 600px) {
  #title-image {
    content: url("images/title_phone.png");
  }

  .game-board {
    grid-template-columns: repeat(3, 28vw);
    gap: 2vw;
  }

  .hole {
    width: 28vw;
    height: 28vw;
  }

  .hammer {
    display: none;
  }
}

/*タイトル画面*/
#title-screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#title-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#start-button {
  position: absolute;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);

  padding: 16px 40px;
  font-size: 24px;
  font-weight: bold;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  z-index: 10;
}
/**/

#skip-to-rule-button {
  position: absolute;
  right: 30px;
  bottom: 30px;
  z-index: 10;

  padding: 12px 28px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

#rule-start-button {
  margin-top: 20px;
  padding: 16px 40px;
  font-size: 24px;
  font-weight: bold;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.result-buttons {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.result-buttons button {
  padding: 14px 28px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.mole {
  background-image: url("images/mole.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

.dead {
  background-image: url("images/mole_dead.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

#story-screen {
  background: black;
  color: #ffd700;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  font-weight: bold;
}

.story-text {
  position: absolute;
  width: 80%;
  left: 10%;
  bottom: -100%;
  text-align: center;
  font-size: 2rem;
  line-height: 1.8;
  animation: story-crawl 15s linear forwards;
}

@keyframes story-crawl {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-220%);
  }
}

#rule-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  z-index: 1000;

  display: flex;
  justify-content: center;
  align-items: center;
}

.rule-box {
  text-align: center;
  background: rgba(255, 255, 255, 0.15);
  padding: 30px;
  border-radius: 20px;
  font-size: 24px;
}

#countdown-screen,
#game-over-screen,
#score-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  z-index: 1000;
  text-align: center;
}

#countdown-screen,
#game-over-screen {
  display: flex;
  justify-content: center;
  align-items: center;
}

.result-box {
  width: min(90%, 420px);
  margin: 40px auto 0;
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.15);
}

#countdown-text,
#game-over-text {
  font-size: clamp(60px, 15vw, 120px);
  font-weight: bold;
}

#final-score {
  font-size: 72px;
  font-weight: bold;
  color: #ffd700;
  text-align: center;
}

.result-label {
  margin-bottom: 0;
  font-size: 20px;
}

.new-record {
  font-size: 24px;
  font-weight: bold;
  color: #ffea00;
}

.ranking-box ol {
  display: inline-block;
  text-align: left;
  font-size: 22px;
  line-height: 1.8;
}

/*ぶたさん*/
#pig-run-area {
  position: fixed;
  left: 0;
  bottom: 80px;
  width: 100vw;
  height: 160px;
  overflow: hidden;
  pointer-events: none;
}

.running-pig {
  position: absolute;
  left: -100px;
  bottom: 0;
  width: 80px;
  animation: pig-run 4s linear forwards, pig-hop 0.4s ease-in-out infinite;
  z-index: 9999;
}

@keyframes pig-run {
  from {
    left: -100px;
  }

  to {
    left: 100vw;
  }
}

@keyframes pig-hop {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-25px);
  }
}

.running-mother-pig {
  position: absolute;
  left: -200px;
  bottom: 0;
  width: 180px;
  animation: mother-pig-run 3.2s linear forwards, mother-pig-rage 0.3s ease-in-out infinite;
  z-index: 10000;
  filter: drop-shadow(0 0 8px rgba(255, 0, 0, 0.7));
}

@keyframes mother-pig-run {
  from {
    left: -160px;
  }

  to {
    left: 100vw;
  }
}

@keyframes mother-pig-rage {
  0%, 100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-30px) rotate(4deg);
  }
}

.pig {
  background-image: url("images/play_pig.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

.pig-dead {
  background-image: url("images/play_pig_dead.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

.helmet {
  background-image: url("images/mole_helmet.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

/*頭上に得点*/
.score-popup {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);
  font-size: 32px;
  font-weight: bold;
  pointer-events: none;
  animation: score-popup 0.6s ease-out forwards;
  z-index: 9999;

  text-shadow:
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000;
}

.score-plus {
  color: #ffe600;
}

.score-minus {
  color: #ff4040;
}

.score-helmet {
  color: #ff9f1c;
}

@keyframes score-popup {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50px);
  }
}

.gold {
  background-image: url("images/mole_gold.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
  animation: gold-shine 0.5s infinite alternate;
}

.gold-dead {
  background-image: url("images/mole_gold_dead.png"), url("images/hole.png");
  background-size: 100%, contain;
  background-repeat: no-repeat;
  background-position: center 20px, center;
}

@keyframes gold-shine {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.3);
  }
}