@import url("https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;500;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background-color: #121212;
}

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* タイトル画面 */
#title-screen {
  background-image: url("images/title_kaihen2.png");
  background-size: cover;
  background-position: center;
  position: relative;
}

.title-image {
  position: absolute;
  width: 60%;
  height: 60%;
  object-fit: contain;
  object-position: center;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.title-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
}

.title-content h1 {
  color: white;
  font-size: 3em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  font-family: "Zen Kurenaido", serif;
  background-color: rgba(255, 255, 100, 0.6);
  padding: 20px 40px;
  border-radius: 15px;
  margin-top: 20px;
}

.start-button {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 20px 60px;
  font-size: 1.8em;
  background-color: #f18b1a;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.start-button:hover {
  background-color: rgba(0, 150, 255, 0.9);
}

.start-button:active {
  transform: translateX(-50%) scale(0.95);
}

/* ゲーム説明画面 */
#explanation-screen {
  background-image: url("images/kusamura.png");
  background-size: cover;
  background-position: center;
  background-color: white;
}

.explanation-content {
  text-align: center;
  background-color: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  position: relative;
  margin-top: 60px;
}

.explanation-content h2 {
  font-size: 3.3em;
  color: black;
  position: absolute;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
  text-shadow:
    2px 0 0 #fff,
    -2px 0 0 #fff,
    0 2px 0 #fff,
    0 -2px 0 #fff,
    2px 2px 0 #fff,
    -2px 2px 0 #fff,
    2px -2px 0 #fff,
    -2px -2px 0 #fff,
    3px 0 0 #fff,
    -3px 0 0 #fff,
    0 3px 0 #fff,
    0 -3px 0 #fff;
}

.explanation-content p {
  font-size: 1.2em;
  margin-bottom: 15px;
  color: #666;
  line-height: 1.6;
}

.next-button {
  padding: 12px 30px;
  font-size: 1.2em;
  background-color: #00a86b;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-top: 20px;
}

.next-button:hover {
  background-color: #00c87c;
}

.next-button:active {
  transform: scale(0.98);
}

/* ゲーム画面 */
#game-screen {
  background-color: #e8f5e9;
  background-image: url("images/kusamura.png");
  background-size: cover;
  background-position: center;
  position: relative;
}

.hehe-control {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.hehe-label {
  font-family: Arial, sans-serif;
  font-size: 1.15em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.04em;
}

.hehe-toggle {
  width: 70px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a2f3a 0%, #151923 100%);
  cursor: pointer;
  position: relative;
  font-size: 0;
  color: transparent;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.12),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35),
    0 8px 14px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.12s ease,
    box-shadow 0.2s ease;
}

.hehe-toggle::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #e9e9e9 70%);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.85);
  transition: transform 0.18s ease;
}

.hehe-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffb000 0%, #f08a00 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    inset 0 -2px 4px rgba(139, 58, 0, 0.35),
    0 10px 18px rgba(0, 0, 0, 0.25);
}

.hehe-toggle[aria-pressed="true"]::after {
  transform: translateX(38px);
}

.hehe-toggle:hover {
  transform: translateY(-1px);
}

.hehe-toggle:active {
  transform: translateY(0) scale(0.98);
}

#evolution-screen {
  background-color: #e8f5e9;
  background-image: url("images/kusamura.png");
  background-size: cover;
  background-position: center;
  position: relative;
  font-family: "Zen Kurenaido", serif;
}

.evolution-effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.evolution-effects::before,
.evolution-effects::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
}

.evolution-effects::before {
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(255, 255, 255, 0.6),
      transparent 35%
    ),
    radial-gradient(
      circle at 80% 25%,
      rgba(255, 255, 255, 0.45),
      transparent 40%
    ),
    radial-gradient(
      circle at 70% 70%,
      rgba(255, 245, 200, 0.55),
      transparent 45%
    ),
    radial-gradient(
      circle at 30% 75%,
      rgba(255, 245, 200, 0.45),
      transparent 40%
    );
  filter: blur(1px);
}

.evolution-effects::after {
  background: repeating-linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.18) 0,
    rgba(255, 255, 255, 0.18) 6px,
    rgba(255, 255, 255, 0) 6px,
    rgba(255, 255, 255, 0) 18px
  );
  mix-blend-mode: screen;
}

.evolution-halo,
.evolution-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.evolution-halo {
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 245, 200, 0.7) 42%,
    rgba(255, 245, 200, 0) 70%
  );
  filter: blur(2px);
}

.evolution-rays {
  width: 540px;
  height: 540px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 250, 210, 0) 0deg 12deg,
    rgba(255, 250, 210, 0.45) 12deg 18deg
  );
  filter: blur(1px);
}

.evolution-title {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  color: #0c2f4a;
  font-size: clamp(1.8em, 3.2vw, 2.6em);
  letter-spacing: 0.08em;
  text-shadow:
    2px 0 0 #fff,
    -2px 0 0 #fff,
    0 2px 0 #fff,
    0 -2px 0 #fff,
    2px 2px 0 #fff,
    -2px 2px 0 #fff,
    2px -2px 0 #fff,
    -2px -2px 0 #fff;
  margin: 0;
  z-index: 4;
}

.evolution-counter {
  z-index: 4;
  font-family: Arial, sans-serif;
}

.evolution-image {
  max-width: 65%;
  max-height: 65%;
  opacity: 0;
}

.hako-image {
  position: absolute;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 300%;
  max-height: 100%;
  object-fit: contain;
  z-index: 2;
}

.years-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 55%;
  max-height: 55%;
  object-fit: contain;
  z-index: 3;
}

#years-image {
  transition:
    transform 0.08s ease,
    filter 0.08s ease;
}

#years-image:active {
  transform: translate(-50%, -50%) scale(0.96);
  filter: brightness(0.95);
}

#evolution-screen.active .evolution-halo {
  animation:
    haloFade 2.4s ease-out forwards,
    haloPulse 2.6s ease-in-out 1.4s infinite;
}

#evolution-screen.active .evolution-rays {
  animation:
    raysFade 2.2s ease-out forwards,
    raysSpin 8s linear 0.2s infinite;
}

#evolution-screen.active .evolution-effects::before {
  animation:
    sparkFade 2.2s ease-out forwards,
    sparkDrift 5s ease-in-out 1.6s infinite;
}

#evolution-screen.active .evolution-effects::after {
  animation:
    sheenFade 2.1s ease-out forwards,
    sheenSweep 6s linear 1.4s infinite;
}

#evolution-screen.active .evolution-image {
  animation:
    angelFade 2.1s ease-out forwards,
    angelFloat 3.6s ease-in-out 1.4s infinite;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.65))
    drop-shadow(0 0 40px rgba(255, 240, 180, 0.45));
}

@keyframes haloFade {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes haloPulse {
  0%,
  100% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
}

@keyframes raysFade {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

@keyframes raysSpin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes angelFade {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes angelFloat {
  0%,
  100% {
    transform: translate(-50%, -50%) translateY(0);
  }
  50% {
    transform: translate(-50%, -50%) translateY(-8px);
  }
}

@keyframes sparkFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.85;
  }
}

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

@keyframes sheenFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.45;
  }
}

@keyframes sheenSweep {
  from {
    transform: translateX(-20%);
  }
  to {
    transform: translateX(20%);
  }
}

.back-home-button {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 30px;
  font-size: 1.1em;
  background-color: rgba(100, 150, 200, 0.8);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 0.3s;
  z-index: 4;
}

.back-home-button:hover {
  background-color: rgba(100, 150, 200, 0.9);
}

.back-home-button:active {
  transform: translateX(-50%) scale(0.95);
}

/* 退出確認モーダル */
.exit-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.35);
  z-index: 6;
}

.exit-modal[hidden] {
  display: none;
}

.exit-modal__card {
  background-color: #ffffff;
  border: 2px solid #111;
  border-radius: 6px;
  padding: 20px 24px 24px;
  width: min(720px, 88vw);
  text-align: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.exit-modal__card--message {
  padding: 24px 32px;
}

.exit-modal__title,
.exit-modal__subtitle {
  margin: 0;
  color: #111;
  line-height: 1.6;
}

.exit-modal__title {
  font-size: 1.2em;
  margin-bottom: 6px;
}

.exit-modal__subtitle {
  font-size: 1.2em;
  margin-bottom: 16px;
}

.exit-modal__actions {
  display: flex;
  justify-content: space-between;
  margin: 0 24px;
  font-size: 1.1em;
}

.exit-modal__button {
  background: none;
  border: none;
  color: #111;
  font-size: 1.1em;
  cursor: pointer;
  padding: 6px 18px;
}

.exit-modal__button--center {
  display: block;
  margin: 12px auto 0;
}

.exit-modal__button:hover {
  text-decoration: underline;
}

/* 連打計数 */
.tap-counter {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  background-color: #ffffff;
  padding: 18px 26px;
  border-radius: 16px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.tap-counter p {
  font-size: 1.4em;
  color: #2a2a2a;
  margin: 0;
  font-weight: bold;
}

#tap-count {
  color: #ff6b6b;
  font-weight: bold;
}

#evolution-tap-count {
  color: #ff6b6b;
  font-weight: bold;
}

/* セリフ表示 */
.dialogue-box {
  position: absolute;
  top: 40%;
  right: 80px;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 15px 20px;
  border-radius: 10px;
  border: 2px solid #333;
  width: 250px;
  height: 100px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialogue-box::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 13px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 12px solid #333;
}

.dialogue-box::after {
  content: "";
  position: absolute;
  left: -10px;
  top: 15px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid rgba(255, 255, 255, 0.95);
}

.dialogue-box--event {
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
  width: min(720px, 86vw);
  height: auto;
  padding: 22px 28px;
  border-radius: 6px;
  background-color: #ffffff;
  text-align: center;
}

.dialogue-box--event::before,
.dialogue-box--event::after {
  display: none;
}

.dialogue-box--event #dialogue-text {
  font-size: 1.1em;
}

.dialogue-box.show {
  opacity: 1;
}

#dialogue-text {
  margin: 0;
  font-size: 1em;
  color: #333;
  line-height: 1.4;
}

/* 結果画面 */
#result-screen {
  background-color: #f7f2e8;
  background-image: radial-gradient(#ece3d3 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Zen Kurenaido", serif;
}

.result-panel {
  width: min(1000px, 92vw);
  height: min(560px, 86vh);
  background-color: #fffaf2;
  border: 3px solid #2a2a2a;
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.15);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 48px;
}

.result-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  color: #222;
}

.result-title {
  font-size: 3.2em;
  margin: 0;
  letter-spacing: 0.08em;
}

.result-lines {
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 1.4em;
}

.result-lines p {
  margin: 0;
}

.result-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border: 3px solid #2a2a2a;
  padding: 12px;
}

.result-photo img {
  width: 75%;
  height: 75%;
  object-fit: contain;
}

.result-button {
  align-self: flex-start;
  padding: 14px 48px;
  border-radius: 999px;
  border: 3px solid #2a2a2a;
  background-color: #fff;
  font-size: 1.2em;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.result-button:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.15);
}

.result-button:active {
  transform: translateY(0);
  box-shadow: none;
}

@media (max-width: 900px) {
  .result-panel {
    grid-template-columns: 1fr;
    height: auto;
  }

  .result-photo {
    height: 260px;
  }

  .result-button {
    align-self: center;
  }
}

/* ストーリー画面 */
.story-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px 40px 40px 240px;
}

.story-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  color: white;
  font-size: 1.2em;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-weight: 500;
  text-align: left;
  margin-bottom: 40px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  overflow-y: auto;
  padding-top: 65px;
}

.story-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
  padding-right: 60px;
}

.next-wrap {
  position: relative;
  display: inline-block;
}

#audio-warning {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  background-color: #121212;
  padding: 20px 30px;
  border-radius: 6px;
  font-size: 16px;
  white-space: normal;
  text-align: center;
  z-index: 1000;
}

#next-button {
  padding: 12px 30px;
  font-size: 1.1em;
  background-color: #121212;
  color: white;
  border: 2px solid white;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  margin: 12px 0 0 0;
  /* 右寄せにするため位置調整は .story-actions の padding-right で行う */
}

#next-button:hover {
  background-color: #1a1a1a;
}

#next-button:active {
  transform: scale(0.98);
}
