@font-face {
  font-family: 'EchionFont';
  src: url('./Echion_Regular.otf') format('opentype');
}

.effect {
  font-family: 'EchionFont', sans-serif;
  position: absolute;
}

:root {
  --bg-sky: #d8f0ff;
  --bg-grass: #b8e6a3;
  --panel: rgba(255, 255, 255, 0.9);
  --text: #1b2a31;
  --accent: #e14d2a;
  --ok: #1d9b5f;
  --miss: #b70000;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--text);
}

body {
  background: linear-gradient(180deg, var(--bg-sky) 0%, #e9f9ff 40%, var(--bg-grass) 100%);
}

#game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: clamp(16px, 4.6vw, 22px);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.in-game-settei-btn {
  width: clamp(36px, 9vw, 52px);
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  transition: transform 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
}

.in-game-settei-btn:active {
  transform: scale(0.9);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)) brightness(0.85);
}

/* ゲーム中設定モーダル */
.in-game-settings-modal {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.in-game-settings-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px 20px;
  width: min(88vw, 320px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.in-game-settings-card h2 {
  margin: 0 0 20px;
  font-size: clamp(20px, 5vw, 26px);
  color: var(--text);
}

.in-game-settings-card .volume-control {
  margin: 14px 0;
  text-align: left;
}

.in-game-settings-card .volume-control label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: clamp(14px, 4vw, 16px);
}

.in-game-settings-card .volume-control input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  appearance: none;
  background: #ddd;
  cursor: pointer;
}

.in-game-settings-card .volume-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3ab86f;
  cursor: pointer;
}

.ig-title-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px 20px;
  font-size: clamp(15px, 4vw, 17px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #e86a3a, #c0392b);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(192,57,43,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}

.ig-title-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(192,57,43,0.35);
}

.ig-close-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 20px;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 600;
  color: #fff;
  background: #777;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}

.ig-close-btn:active {
  transform: translateY(1px);
}

.chip {
  background: var(--panel);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}

#field {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.fly {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  display: block;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.25));
  transition: transform 0.08s ease-out, filter 0.08s ease-out;
  will-change: left, top, transform;
}

.fly.hit {
  transform: translate(-50%, -50%) scale(0.9);
  filter:
    drop-shadow(0 0 8px rgba(255, 50, 50, 0.9)) saturate(5) hue-rotate(-20deg);
}


.fly-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.effect {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-weight: 900;
  font-size: clamp(22px, 7vw, 42px);
  animation: pop 0.5s ease-out forwards;
}

.effect.hit {
  font-family: 'EchionFont', sans-serif;
  color: #da87bb;

  font-size: clamp(22px, 7vw, 42px);
  display: inline-block;
  transform: translate(-50%, -50%) scaleX(0.65);
  letter-spacing: -0.2em;
}

.effect.miss {
  font-family: 'EchionFont', sans-serif;
  color: #000;

  font-size: clamp(22px, 7vw, 42px);
  font-size: clamp(16px, 6vw, 32px);
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }

  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-24px) scale(1);
  }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
}

.card {
  width: min(92vw, 380px);
  background: #fff;
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.card h1 {
  margin: 4px 0 8px;
  font-size: clamp(24px, 7vw, 34px);
}

.card p {
  margin: 0 0 16px;
  font-size: clamp(14px, 4vw, 18px);
  line-height: 1.5;
}

.card button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #3ab86f, var(--ok));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.card button:active {
  transform: translateY(1px);
}

.hide {
  display: none;
}

.title-logo {
  width: 200px;
  width: 60%;
  height: auto;
}

.title-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.title-screen img {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  object-fit: cover;    /* 画面全体を埋める（端は少し切れる可能性があります） */
  cursor: pointer;
}

.title-screen.title2-screen {
  background: #000000;
}

.title2-screen .title2-container {
  position: relative;
  width: 100%;
  height: 100%;
  /* コンテナ自体を中央揃えの土台にする */
  display: flex;
  align-items: center;
  justify-content: center;
}

.title2-screen .title2-bg {
  width: 100vw;       /* 画面の横幅いっぱい(100%)にする */
  height: auto;       /* 縦横比を維持 */
  max-width: none;    /* 最大幅の制限を消す */
  max-height: none;   /* 最大高さの制限を消す */
  
  position: absolute;
  top: 50%;           /* 真ん中に配置 */
  left: 50%;
  transform: translate(-50%, -50%);
  object-fit: contain;
}

.title2-screen .settei-btn {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 65px;
  width: clamp(60px, 15vw, 100px);
  height: auto;
  cursor: pointer;
  z-index: 10;
}

.title2-screen .start-btn {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(180px, 40vw, 300px);
  height: auto;
  cursor: pointer;
  z-index: 10;
}

.settings-modal {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
}

.settings-modal .settings-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: min(85vw, 320px);
  text-align: center;
}

.settings-modal h2 {
  margin: 0 0 20px;
  font-size: clamp(20px, 5vw, 26px);
}

.settings-modal .volume-control {
  margin: 16px 0;
  text-align: left;
}

.settings-modal .volume-control label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: clamp(14px, 4vw, 16px);
}

.settings-modal .volume-control input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  appearance: none;
  background: #ddd;
  cursor: pointer;
}

.settings-modal .volume-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3ab86f;
  cursor: pointer;
}

.settings-modal .close-btn {
  margin-top: 20px;
  padding: 10px 24px;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 600;
  color: #fff;
  background: #666;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.hide {
  display: none !important;
}

.ranking-container {
  position: absolute;
  top: 60%;
  right: 5%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 10px 15px;
  z-index: 50;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  width: clamp(140px, 30vw, 200px);
  font-size: clamp(12px, 3vw, 16px);
  text-align: left;
  color: var(--text);
}
.ranking-container h3 {
  margin: 0 0 8px 0;
  font-size: 1.1em;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
  text-align: center;
}
.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ranking-list li {
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: bold;
}
.ranking-list li span:last-child {
  color: var(--ok);
}

.dobon-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.dobon-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.dobon-img {
  max-width: 80vw;
  max-height: 80vh;
  width: 60%;
  object-fit: cover;
  transform: scale(0.1);
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.dobon-overlay.show .dobon-img {
  transform: scale(1);
}
.dobon-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: clamp(48px, 15vw, 120px);
  font-weight: bold;
  color: #ff4444;
  text-shadow: 4px 4px 8px rgba(0,0,0,0.8);
  opacity: 0;
  transition: all 0.5s ease-out;
  font-family: 'EchionFont', sans-serif;
}
.dobon-overlay.show .dobon-text {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  animation: dobonPulse 0.8s ease-out 1.2s;
}
@keyframes dobonPulse {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.unlocked-info {
  color: var(--accent);
  font-weight: bold;
  margin: 10px 0;
  font-size: clamp(14px, 4vw, 18px);
  animation: pop 0.5s ease-out;
}

.customize-hint {
  color: #666;
  font-size: clamp(12px, 3vw, 14px);
  margin: 8px 0;
  font-weight: normal;
}

#game {
  border: 12px solid #ffd7f1; /* ピンク色 */
  border-radius: 20px;       /* 角を少し丸くすると可愛くなります */
}

/* カスタマイズ画面 */
.customize-modal {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
}

.customize-modal .customize-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: min(90vw, 380px);
  max-height: 80vh;
  text-align: center;
  overflow-y: auto;
}

.customize-modal h2 {
  margin: 0 0 8px;
  font-size: clamp(20px, 5vw, 26px);
}

.customize-modal p {
  margin: 0 0 16px;
  font-size: clamp(14px, 4vw, 16px);
  color: #666;
}

.oshiri-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.oshiri-item {
  position: relative;
  border: 2px solid #ddd;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.oshiri-item:hover {
  border-color: #3ab86f;
  box-shadow: 0 2px 8px rgba(58, 184, 111, 0.3);
}

.oshiri-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f5f5f5;
  display: block;
}

.oshiri-checkbox {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #3ab86f;
}

.oshiri-item.locked {
  opacity: 0.3;
  filter: grayscale(100%);
  cursor: not-allowed;
}

.oshiri-item.locked img {
  pointer-events: none;
}

.customize-modal .close-btn {
  margin-top: 16px;
  padding: 10px 24px;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 600;
  color: #fff;
  background: #666;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
}

.result-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  max-width: 95vw;
  z-index: 50;
}

/* アフィリエイトコンテナのスタイリング */
.affiliate-container {
  width: min(40vw, 220px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 10px;
  transition: opacity 0.3s ease;
  pointer-events: auto;
  line-height: 0;
}

.affiliate-container.hide {
  display: none !important;
}

@media (max-width: 768px) {
  .result-wrapper {
    flex-direction: column;
    gap: 15px;
  }
  .affiliate-container {
    width: min(85vw, 320px);
  }
}

.affiliate-container a {
  display: block;
  text-decoration: none;
}

.affiliate-container img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}

/* 広告スタイル */
.pc-ad {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 40;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  min-height: 250px;
  min-width: 160px;
}

.pc-ad .ad-label {
  font-size: 10px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.sp-ad {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #e5e7eb;
  padding-top: 4px;
  padding-bottom: 4px;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  min-height: 60px;
}

@media (min-width: 768px) {
  .pc-ad {
    display: flex;
  }
}

@media (min-width: 768px) {
  .sp-ad {
    display: none;
  }
}