/* 全体リセット系は最小限に */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic", sans-serif;
  color: #fdfdfd;
  background-color: #020410;
}

/* 汎用：どの画面でも使える非表示クラス */
.hidden {
  display: none !important;
}


/* 画面共通レイアウト */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* 背景：画面ごとのイラスト */
.screen {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  display: none; /* デフォルトは非表示 */
}

/* タイトル画面専用の背景（本体には背景を持たせない） */
#screen-home {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100svh;
  background: #000; /* 余白の色 */
}

/* 背面：ぼかし（cover） */
#screen-home::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../img/bg_title.webp");
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(0.6);
  transform: scale(1.06);      /* blurの端切れ対策 */
  z-index: 0;
  pointer-events: none;
}

/* 前面：くっきり（contain） */
#screen-home::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../img/bg_title.webp");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  z-index: 1;
  pointer-events: none;
}

/* UIは最前面 */
#screen-home .overlay {
  position: relative;
  z-index: 2;
}


.screen.active {
  display: block;
}

/* オーバーレイ：黒い透過レイヤーは削除して、背景をそのまま見せる */
.overlay {
  width: 100%;
  height: 100%;
  /* 背景を透明にして、背景イラストをはっきり見せる */
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 140px;
}

/* 会話・テキスト系の画面用（余白多め） */
.overlay.simple {
  justify-content: center;     /* ←中央寄せ（縦）*/
  align-items: center;         /* ←中央寄せ（横）*/
  padding-top: 80px;           /* ←上のボタンに余裕を作るため */
  padding-bottom: 80px;        /* ←必要なら調整 */
}

/* =========================
   Stage Select: Pure black background
   ========================= */
#screen-stage-select {
  background-color: #000;
  background-image: none; /* 念のため画像を無効化 */
}


/* タイトルボックス（今は未使用だが残しておく） */
.title-box {
  text-align: center;
  margin-bottom: 40px;
}

.game-title {
  font-size: 2.4rem;
  letter-spacing: 0.15em;
  text-shadow: 0 0 8px rgba(255, 192, 255, 0.7);
}

.game-subtitle {
  margin-top: 8px;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* メニュー共通 */
.menu-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(320px, 90vw);
  margin-top: 0;
  align-items: center;   /* 横中央揃え */
}


/* ボタン共通スタイル */
.btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, #ff6bd4, #ffc46b);
  color: #1c0414;
  box-shadow: 0 6px 16px rgba(255, 120, 220, 0.55);
}

.btn.secondary {
  background: rgba(7, 10, 40, 0.9);
  color: #f5f5ff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.btn.ghost {
  width: auto;
  padding-inline: 14px;
  background: transparent;
  color: #f5f5ff;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  font-weight: 500;
}

.btn.stage-btn {
  text-align: left;
  font-size: 0.9rem;
}

.btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ボタンのちょっとしたアニメーション */
.btn:active:not(.disabled) {
  transform: translateY(1px) scale(0.98);
  box-shadow: none;
}

/* スタートボタン文字サイズ */
#btn-start {
  font-size: 1.6rem;    /* ← 好きな大きさに調整 */
  padding: 18px 24px;   /* ← ボタン自体も少し大きく */
}

/* 下部の注意書きなど */
.footer-info {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.9;
}

/* プロローグやステージ説明のレイアウト */
.header-row {
  display: flex;
  justify-content: flex-start;
  padding: 12px 12px 0 12px;
}

.text-box {
  width: min(600px, 90vw);   /* ←中央に置いたときの幅 */
  margin: 0 auto 24px auto; /* ←中央揃え & 下に少し余白 */
  padding: 16px;
  background: rgba(3, 5, 25, 0.85);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-height: calc(100vh - 170px);
  overflow-y: auto;
}

.text-box h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.text-box p {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ステージボタンリスト */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

/* スマホ向け微調整 */
@media (min-width: 768px) {
  .game-title {
    font-size: 3rem;
  }

  .text-box {
    max-width: 640px;
    margin-inline: auto;
  }
}


/* キャラ名表示 */
.char-name {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  opacity: 0.9;
}

/* プロローグ本文 */
.prologue-text {
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap; /* \n をそのまま改行として扱う */
}



/* =========================
   Common UI: Dialog (bottom fixed)
   ========================= */

.ui-dialog {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  height: 25vh;                 /* ★ 画面下 1/4 固定 */
  padding: 14px 16px;
  box-sizing: border-box;

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

  z-index: 50;
}

/* 中身（実際の台詞箱） */
.ui-dialog .ui-text {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;

  background: rgba(3, 5, 25, 0.72);  /* ★ 透過はここだけ触る */
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;

  padding: 16px 18px;
  box-sizing: border-box;

  font-size: 0.98rem;
  line-height: 1.65;
  color: #f7f7ff;
  white-space: pre-wrap;

  overflow-y: auto;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* キャラ名（使うなら） */
.ui-dialog .ui-name {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  opacity: 0.95;
  margin-bottom: 6px;
}

/* 下部ボタン列（今は未使用でも残してOK） */
.ui-dialog .ui-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* 非表示 */
.ui-dialog.hidden {
  display: none !important;
}



/* =========================
   Common UI: Timer (bar)
   ========================= */

.ui-timer {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 60;

  width: auto;
  max-width: 720px;
  margin: 0 auto;

  padding: 10px 12px;
  border-radius: 14px;

  background: rgba(3, 5, 25, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

/* 上段：ラベル＋残り秒（任意で表示） */
.ui-timer__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ui-timer__label {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.ui-timer__value {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.95;
}

/* バー土台 */
.ui-timer__track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.10);
}

/* バー本体：幅をJSで変える */
.ui-timer__bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;

  /* “挑戦する”ボタンに寄せた雰囲気 */
  background: linear-gradient(135deg, #ff6bd4, #ffc46b);
  box-shadow: 0 0 14px rgba(255, 120, 220, 0.35);

  transform-origin: left center;
  transition: width 0.08s linear;
}

/* ピンチ時（残り少ない）に付けるクラス：点滅 */
.ui-timer.is-urgent .ui-timer__bar {
  animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

/* こよりプロローグ：背景切替の“ポップ”演出 */
#screen-koyori-prologue {
  overflow: hidden; /* 拡大時のはみ出しを隠す */
}

#screen-koyori-prologue.is-bg-pop {
  animation: bgPop 360ms ease;
}

@keyframes bgPop {
  0%   { transform: scale(1.03); filter: blur(3px); }
  100% { transform: scale(1);    filter: blur(0); }
}

/* =========================
   Common UI:Blackout&pop bler
   ========================= */

.prologue-blackout {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 280ms ease;
  z-index: 40;
  pointer-events: none;
}

.prologue-blackout.is-on {
  opacity: 1;
}

.prologue-blackout.hidden {
  display: none !important;
}

.prologue-bg-pop {
  animation: prologueBgPop 360ms ease;
}

@keyframes prologueBgPop {
  0% {
    transform: scale(1.03);
    filter: blur(3px);
  }
  100% {
    transform: scale(1);
    filter: blur(0);
  }
}

/* ===== Prologue screen base ===== */
.prologue-screen {
  position: relative;
  min-height: 100vh;
  background: #000;
  overflow: hidden;
}

/* =========================
   Common: Fullscreen effect layer
   ========================= */
.effect-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1; /* 背景 < エフェクト < UI */
}

/* ★ chloe用フェロモンレイヤー */
.effect-layer-pheromones {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ★ chloe用ハートレイヤー */
.effect-layer-hearts {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* =========================
   Common: Hearts (image)
   ========================= */

/* 中心基準のラッパー */
.heart-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  /* transform は hearts.js が毎回上書きするのでここでは書かない */
}

/* ハート本体 */
.heart {
  position: absolute;
  top: 0;
  left: 0;

  opacity: 0;
  transform-origin: center center;

  animation-name: heart-float-out;
  animation-timing-function: linear;
  animation-fill-mode: forwards;

  will-change: transform, opacity;
}

/* 中央から外側へスムーズに広がる（こよりstyleの挙動を共通化） */

/* ★ フェロモンエフェクト */
.pheromones-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  /* transform は pheromones.js が毎回上書きするのでここでは書かない */
}

/* フェロモン本体 */
.pheromones {
  position: absolute;
  top: 0;
  left: 0;

  opacity: 0;
  transform-origin: center center;

  animation-name: pheromone-float-out;
  animation-timing-function: linear;
  animation-fill-mode: forwards;

  will-change: transform, opacity;
}

@keyframes pheromone-float-out {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }
  15% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.15), calc(var(--ty) * 0.15))
      scale(0.7) rotate(-6deg);
  }
  60% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.7), calc(var(--ty) * 0.7))
      scale(1.1) rotate(6deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty))
      scale(1.4) rotate(0deg);
  }
}
@keyframes heart-float-out {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }
  15% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.15), calc(var(--ty) * 0.15))
      scale(0.7) rotate(-6deg);
  }
  60% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.7), calc(var(--ty) * 0.7))
      scale(1.1) rotate(6deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty))
      scale(1.4) rotate(0deg);
  }
}


/* =========================
   Common: Flash overlay (white)
   ========================= */
.flash-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 80;
  transition: opacity 0.35s linear;
}
.flash-overlay.visible {
  opacity: 1;
}

/* =========================
   Common: Fade overlay (black)
   ========================= */
.fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  transition: opacity 0.7s ease;
}
.fade-overlay.is-visible {
  opacity: 1;
  pointer-events: auto; /* 真っ暗中にタップ検知したいなら */
}

/* =========================
   Common: GameOver modal
   ========================= */
.gameover-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.55);
}

.gameover-panel {
  width: 90%;
  max-width: 360px;
  background: rgba(5, 5, 16, 0.92);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 20px 16px;
  text-align: center;
}

.gameover-title {
  font-size: 1.6rem;
  margin: 0 0 16px;
}

.gameover-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.gameover-message {
  margin: 12px 0 14px;
  min-height: 2.6em;
  line-height: 1.7;
  font-size: 16px;
  color: var(--text-main);
  text-align: center;
  white-space: pre-wrap;
}

.gameover-buttons.hidden {
  display: none;
}


/* =========================
   Common: Hide UI for dramatic moments
   ========================= */
.screen.is-ui-hidden .ui-timer,
.screen.is-ui-hidden .game-container {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s linear;
}

/* Chloeのゲーム要素を個別に隠す（台詞UIは除く） */
.screen.is-ui-hidden .ui-header,
.screen.is-ui-hidden .tap-area,
.screen.is-ui-hidden .controls {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s linear;
}

/* =========================
   Common: Bukkake overlay (global asset)
   ========================= */
.bukkake-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2; /* 背景(0) < ぶっかけ(2) < UI/ダイアログなど(>=3) */

  background-image: url("../img/bukkake.webp"); /* ★ここで固定 */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  opacity: 1;
}

/* showクラスは将来の演出変更に備えて維持（現状は同値） */
.bukkake-overlay.show {
  opacity: 1;
}

.bukkake-overlay.hidden {
  display: none !important;
}

/* 共通：確実に非表示にする */
.hidden {
  display: none !important;
}

/* =========================
   Common: Prologue bg pop effect
   ========================= */

.prologue-screen.is-bg-pop {
  animation: bgPop 360ms ease;
}

@keyframes bgPop {
  0%   { transform: scale(1.03); filter: blur(3px); }
  100% { transform: scale(1);    filter: blur(0); }
}

/* =========================
   Common: Prologue stand fade-in
   ========================= */

.stand {
  opacity: 0;
  transition: opacity 1s ease;
}

.stand.fade-in {
  opacity: 1;
}


/* =========================
   Preloader Screen
   ========================= */

#preloader-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader-screen.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-content {
  text-align: center;
  padding: 20px;
}

.preloader-title {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 30px;
  text-shadow: 0 2px 10px rgba(255, 105, 180, 0.5);
}

.preloader-bar-container {
  width: 300px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.preloader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff69b4 0%, #ff1493 50%, #ff69b4 100%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 10px;
  transition: width 0.3s ease;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.preloader-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 10px;
}

@media (max-width: 600px) {
  .preloader-title {
    font-size: 20px;
  }
  
  .preloader-bar-container {
    width: 250px;
  }
}

