/* ==========================================================
   モンスター・カタパルト - style.css
   ========================================================== */

:root {
  --color-bg-top: #bfe6ff;
  --color-bg-bottom: #ffe9c4;
  --color-primary: #ff7a3d;
  --color-primary-2: #4fa8ff;
  --color-accent: #ffd23f;
  --color-danger: #ff5d5d;
  --color-text: #4a3b2c;
  --color-text-muted: #8d7a63;
  --color-border: #ffffff;
  --color-panel: #fffaf2;
  --header-h: 56px;
  --score-h: 52px;
  --ad-h: 64px;
  --ad-gap-h: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--color-bg-top), var(--color-bg-bottom));
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.7rem;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 3px solid #fff;
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 rgba(74, 59, 44, 0.15);
  flex: 0 0 auto;
}

.back-link:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(74, 59, 44, 0.15);
}

.game-title {
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  margin: 0 0.4rem;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--color-text);
  font-size: 1.02rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(74, 59, 44, 0.15);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(74, 59, 44, 0.15);
}

.icon-btn.is-muted {
  color: var(--color-text-muted);
  opacity: 0.65;
}

/* ---------- スコアバー ---------- */
/* ステージによって弾（モンスター）の数が変わるので、
   折り返してもはみ出さないよう高さは auto にしておく（固定だと下段が切れる） */
.score-bar {
  min-height: var(--score-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  z-index: 15;
  flex-wrap: wrap;
  padding: 0.25rem 0.4rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 2px 0 rgba(74, 59, 44, 0.1);
}

.stat-box__label {
  font-size: 0.62rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.stat-box__value {
  font-size: 0.98rem;
  font-weight: 900;
  color: var(--color-primary);
}

/* 残りモンスター（弾）の表示 */
.lives-box {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  box-shadow: 0 2px 0 rgba(74, 59, 44, 0.1);
  min-height: 28px;
}

.ammo-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(74, 59, 44, 0.3);
}

.ammo-dot--used {
  opacity: 0.25;
  filter: grayscale(1);
}

.ammo-dot--red { background: #ff5d6c; }
.ammo-dot--blue { background: #4da6ff; }
.ammo-dot--purple { background: #a259e6; }

/* ---------- ゲームステージ ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.74rem;
  font-weight: bold;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed var(--color-primary);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  max-width: 92%;
  text-align: center;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.control-hint.is-hidden {
  opacity: 0;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(60, 45, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay__box {
  text-align: center;
  padding: 1.6rem 1.8rem;
  background: var(--color-panel);
  border: 4px solid #fff;
  border-radius: 26px;
  max-width: 88%;
  box-shadow: 0 20px 50px rgba(60, 45, 30, 0.35);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay__title {
  font-size: 1.35rem;
  font-weight: 900;
  margin: 0 0 0.4rem;
  color: var(--color-primary);
}

.overlay__stars {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
  letter-spacing: 0.15rem;
  line-height: 1.1;
}

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  font-weight: bold;
  white-space: pre-line;
  line-height: 1.5;
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), #ffb066);
  color: #fff;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c9552a;
}

.overlay__btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c9552a;
}

.overlay__btn-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.overlay__btn--sub {
  background: linear-gradient(135deg, #8fb6ff, #7fd7ff);
  box-shadow: 0 4px 0 #5271b0;
}

.overlay__btn--sub:active {
  box-shadow: 0 1px 0 #5271b0;
}

.overlay__btn.is-hidden {
  display: none;
}

/* ---------- デモモード ---------- */
.demo-caption {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 25;
  max-width: 90%;
  font-size: 0.82rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), #ff5d6c);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(60, 45, 30, 0.35);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.demo-caption.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.demo-start-btn {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) scale(0.9);
  z-index: 25;
  border: none;
  background: linear-gradient(135deg, var(--color-primary), #ffb066);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c9552a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  animation: demo-pulse 1.6s ease-in-out infinite;
}

.demo-start-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

@keyframes demo-pulse {
  0%, 100% { box-shadow: 0 4px 0 #c9552a, 0 4px 14px rgba(255, 122, 61, 0.4); }
  50% { box-shadow: 0 4px 0 #c9552a, 0 4px 22px rgba(255, 122, 61, 0.8); }
}

/* ---------- ガイド画面 ---------- */
.guide-section {
  text-align: left;
  margin: 1rem 0;
}

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-primary);
  margin: 0 0 0.4rem;
}

.guide-section__text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.6;
}

.guide-section__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.7;
}

.guide-section__list li {
  margin-bottom: 0.3rem;
}

/* ---------- 広告スペース ---------- */
.ad-gap {
  flex: 0 0 var(--ad-gap-h);
  background: var(--color-bg-bottom);
}

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 2px dashed var(--color-primary);
  background: rgba(255, 255, 255, 0.6);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  z-index: 20;
  overflow: hidden;
}

@media (max-height: 640px) {
  .ad-slot {
    --ad-h: 44px;
    font-size: 0.65rem;
  }
  .ad-gap {
    --ad-gap-h: 10px;
  }
}

@media (max-width: 460px) {
  .score-bar {
    gap: 0.25rem;
  }
  .stat-box {
    padding: 0.16rem 0.45rem;
    gap: 0.25rem;
  }
  .stat-box__label {
    font-size: 0.55rem;
  }
  .stat-box__value {
    font-size: 0.86rem;
  }
  .lives-box {
    padding: 0.16rem 0.35rem;
    gap: 0.12rem;
    min-height: 24px;
  }
  .ammo-dot {
    width: 11px;
    height: 11px;
    border-width: 1.5px;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 0.74rem;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}
