@charset "UTF-8";

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

body {
  font-family: "vdl-megamaru", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative; /* pseudo-element を body の背面に置くため */
  z-index: 0;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

/* 大きめのマス目を背景に追加（薄い白） */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1; 
  background-image:
    linear-gradient(rgba(0,0,0,0.20) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.20) 1px, transparent 1px);
  background-size: 48px 48px; /* マスの大きさ */
  opacity: 0.28; 
  animation: slideGrid 120s linear infinite;
}

@keyframes slideGrid {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 480px 480px, 480px 480px; /* 斜め方向にゆっくり移動 */
  }
}

/* 結果表示（画像/テキスト）はグリッドより前面に出す */
#resultImage {
  position: relative;
  z-index: 3;
  background: rgba(255,255,255,0.68);
  border-radius: 10px;
  padding: 6px;
}


/* ヘッダーロゴレスポンシブ表示 */
#headerLogo {
  display: block;
  margin: 18px auto;
  width: 80%;
  max-width: 400px; /* モバイル基準*/
  height: auto;
  object-fit: contain;
}

@media (min-width: 601px) {
  #headerLogo {
    max-width: 560px; /* タブレット向け*/
  }
}

@media (min-width: 1024px) {
  #headerLogo {
    max-width: 820px; /* デスクトップ向け */
  }
}

main {
  padding: 2rem;
  border-radius: 20px;
  box-shadow: none;
  text-align: center;
  min-width: 300px;
  margin: 0 20px;
}

#drawButton {
  font-family: "vdl-megamaru", sans-serif;
  font-size: 1.3rem;
  padding: 12px 30px;
  background: #444;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
}

#drawButton:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
  background: #000000;
}

#drawButton:active {
  transform: translateY(0);
}

#resultDisplay {
  display: none;
}

footer {
  position: fixed;
  bottom: 20px;
  font-size: 0.9rem;
}

/* おみくじ結果に応じた背景色とスタイル */

.daikichi_1 {
  background: linear-gradient(135deg, #ffa726, #ffb74d) !important;
  border-color: #ff9800;
}

.daikichi_2 {
  background: linear-gradient(135deg, #f1ff26, #f1ff26) !important;
  border-color: #f1ff26;
}

.daikichi_3 {
  background: linear-gradient(135deg, #3860d0, #3860d0) !important;
  border-color: #3860d0;
}

.daikichi_4 {
  background: linear-gradient(135deg, #ff6b6b, #ff6b6b) !important;
  border-color: #ff6b6b;
}

.daikichi_5 {
  background: linear-gradient(135deg, #6bdfff, #6bdfff) !important;
  border-color: #6bdfff;
}

.daikichi_6 {
  background: linear-gradient(135deg, #ffbcee, #ffbcee) !important;
  border-color: #ffbcee;
}

.daikichi_7 {
  background: linear-gradient(135deg, #7ff4b0, #7ff4b0) !important;
  border-color: #7ff4b0;
}

.daikichi_8 {
  background: linear-gradient(135deg, #ffffff, #ffffff) !important;
  border-color: #ffffff;
}

/* bodyの背景色変更（daikichi_1 ～ daikichi_8 に対応） */
body.daikichi_1 {
  background: linear-gradient(135deg, #fff3e8, #fff8f2);
  transition: background 0.5s ease;
}

body.daikichi_2 {
  background: linear-gradient(135deg, #fffef0, #fffef6);
  transition: background 0.5s ease;
}

body.daikichi_3 {
  background: linear-gradient(135deg, #eef0ff, #f6f7ff);
  transition: background 0.5s ease;
}

body.daikichi_4 {
  background: linear-gradient(135deg, #fff0f0, #fff6f6);
  transition: background 0.5s ease;
}

body.daikichi_5 {
  background: linear-gradient(135deg, #f0fdff, #f7feff);
  transition: background 0.5s ease;
}

body.daikichi_6 {
  background: linear-gradient(135deg, #fff5fb, #fff9fd);
  transition: background 0.5s ease;
}

body.daikichi_7 {
  background: linear-gradient(135deg, #f6fff4, #fbfff8);
  transition: background 0.5s ease;
}

body.daikichi_8 {
  background: linear-gradient(135deg, #ffffff, #ffffff);
  transition: background 0.5s ease;
}


/* 結果画像を中央に表示（初期は非表示、表示はJSで制御） */
#resultImage {
  display: none;
  margin: 24px auto;
  max-width: 90%;
  height: auto;
}

/* モーダル内画像の最大高さを制限して大画面で巨大表示されないようにする */
.image-modal img {
  max-height: 80vh;
}

/* iPadやPCではメインの結果画像を控えめに表示する */
@media (min-width: 601px) {
  #resultImage {
    max-width: 320px;
  }
  .image-modal .modal-box {
    max-width: 640px;
    width: 80%;
  }
}

@media (min-width: 1024px) {
  #resultImage {
    max-width: 420px;
  }
  .image-modal .modal-box {
    max-width: 760px;
    width: 70%;
  }
}

/* モーダルスタイル */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms cubic-bezier(.2,.9,.2,1), visibility 260ms linear;
}

.image-modal.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.image-modal .modal-box {
  position: relative;
  max-width: 920px;
  width: 90%;
  max-height: 90%;
  background: transparent;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;
}

.image-modal img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* 開く時のアニメーション（モーダル表示時に発火） */
.image-modal.open .modal-box {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.modal-save {
  display: inline-block;
  margin-top: 10px;
  background: #444;
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.95rem;
}

/* モーダル内の要素をセンタリング（画像の下にボタンが来る） */
.image-modal .modal-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- ローディングオーバーレイ（可愛い） --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 240ms ease, visibility 240ms linear;
}
.loading-overlay.show {
  visibility: visible;
  opacity: 1;
}
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.loader {
  display: flex;
  gap: 10px;
  align-items: center;
}
.loader .star {
  width: 18px;
  height: 18px;
  display: block;
  fill: #3860d0;
  transform-origin: center;
  animation: loader-pulse 900ms infinite ease-in-out;
}
.loader .star:nth-child(2) { animation-delay: 120ms; }
.loader .star:nth-child(3) { animation-delay: 240ms; }

/* 星の角を丸く見せる：path に丸いストロークを入れる */
.loader .star path {
  stroke: #3860d0;
  stroke-width: 1.6px;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: #3860d0; /* 塗りはそのまま */
}
@keyframes loader-pulse {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-8px) scale(1.15); opacity: 0.9; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.loading-text {
  font-size: 0.95rem;
  color: #333;
  font-weight: 700;
  letter-spacing: .03em;
}

/* モバイル時にローディングボックスを少し大きくする */
@media (max-width: 480px) {
  .loading-box { padding: 14px 18px; border-radius: 12px; }
  .loader span { width: 12px; height: 12px; }
  .loading-text { font-size: 0.9rem; }
}

