/* ============================================================
   絶対彼氏 — ゲーム画面スタイルシート（game.html 用）
   ============================================================

   【ファイル構成】
   このファイルは game.html 専用です。
   トップページのスタイルは css/index.css を参照してください。

   【目次】
   1. カラー変数・フォント変数
   2. リセット・ベース
   3. body（デスクトップ背景）
   4. #game-container（ゲーム全体の枠）
   5. #bg（背景レイヤー）
   6. #chara（立ち絵）
   7. #textbox（テキストボックス）
   8. #choices（選択肢ボタン）
   9. #line-cta（LINE 友だち追加 CTA）
   10. #screen-select（キャラクター選択画面）
   11. #screen-ending（エンディング画面）
   12. #game-view（ゲームビュー）
   13. レスポンシブ対応（横向き端末）

   ============================================================ */


/* ────────────────────────────────────────
   1. カラー変数・フォント変数
   ──────────────────────────────────────
   サイト全体の色はここで一元管理しています。
   色を変えたい場合はこのセクションの値を変更してください。
──────────────────────────────────────── */
:root {
  /* ── メインカラー ── */
  --rose:        #e05e8a;   /* ピンク。話者名・ボーダーなどに使用 */
  --rose-light:  #f9a8c9;   /* 淡いピンク */
  --coral:       #f9607a;   /* コーラル。グラデーションに使用 */
  --sky:         #5ba8d8;   /* スカイブルー（現時点では予備） */
  --lavender:    #9b72cf;   /* ラベンダー。グラデーションの終端に使用 */

  /* ── テキストカラー ── */
  --text-dark:   #3a2040;                /* 本文・見出しの濃い色 */
  --text-mid:    #6b4060;                /* 中間の濃さ。ヒントテキストなど */
  --text-muted:  rgba(58, 32, 64, 0.5);  /* 薄めのテキスト。「違うな…」など */

  /* ── 背景 ── */
  --box-bg: rgba(255, 250, 253, 0.88);   /* テキストボックスの背景（半透明白） */

  /* ── フォント ── */
  --font-serif: 'Hiragino Mincho ProN', 'Yu Mincho', 'Georgia', serif;

  /* ── ゲーム画面サイズ（PC 表示時） ── */
  --game-w: 430px;   /* 幅。スマホ画面を想定した縦長サイズ */
  --game-h: 760px;   /* 高さ */
}

/* 大きめの PC 画面では少し大きく表示 */
@media (min-width: 900px) and (min-height: 860px) {
  :root {
    --game-w: 480px;
    --game-h: 850px;
  }
}


/* ────────────────────────────────────────
   2. リセット・ベース
──────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-serif);
  color: var(--text-dark);
}


/* ────────────────────────────────────────
   3. body（デスクトップ背景）
   PC で表示したときにゲーム枠の外に見える背景。
   スマホでは全画面なので実質見えません。
──────────────────────────────────────── */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 25% 60%, rgba(255, 182, 210, 0.3) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 40%, rgba(173, 216, 255, 0.3) 0%, transparent 55%),
    linear-gradient(160deg, #fff4f8 0%, #fce8f2 45%, #edf4ff 100%);
  min-height: 100vh;
}


/* ────────────────────────────────────────
   4. #game-container（ゲーム全体の枠）
   スマホ：画面いっぱいに広がる
   PC   ：縦長ボックスとして中央に表示
──────────────────────────────────────── */
#game-container {
  position: relative;
  width: 100%;
  height: 100dvh;  /* dvh = Dynamic Viewport Height（ブラウザのUIバーを考慮） */
  overflow: hidden;
}

/* 540px 以上の画面（タブレット・PC）では縦長ボックスに */
@media (min-width: 540px) {
  #game-container {
    width: var(--game-w);
    height: min(100dvh, var(--game-h));
    border-radius: 20px;
    box-shadow:
      0 0 0 1px rgba(224, 94, 138, 0.18),
      0 24px 60px rgba(160, 100, 180, 0.2),
      0 8px 24px rgba(0, 0, 0, 0.12);
  }
}


/* ────────────────────────────────────────
   5. #bg（背景レイヤー）
   JS が background-image を動的に切り替えます。
   背景画像は data/image/bg/ フォルダに格納されています。
──────────────────────────────────────── */
#bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-color: #f0e8f2;  /* 画像が読み込まれるまでのフォールバック色 */
  transition: opacity 0.6s ease;
  z-index: 0;
}

/* JS が .fading クラスを付与することでフェードアウト（切り替え時） */
#bg.fading {
  opacity: 0;
}


/* ────────────────────────────────────────
   6. #chara（立ち絵）
   JS が src を変更し、.visible クラスで表示/非表示を制御します。
   立ち絵画像は data/image/chara/ フォルダに格納されています。

   z-index の層構造：
     0: 背景（#bg）
     1: 立ち絵（#chara）
    10: テキストボックス（#textbox）
    20: 選択肢・LINE CTA
    30: キャラ選択・エンディング画面
──────────────────────────────────────── */
#chara {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);  /* 水平中央揃え */
  height: 80%;
  max-width: 90%;
  object-fit: contain;
  object-position: bottom center;
  z-index: 1;
  opacity: 0;                   /* デフォルトは非表示 */
  transition: opacity 0.4s ease;
  pointer-events: none;         /* クリックを貫通させる */
}

/* JS が .visible を付与するとフェードインで表示される */
#chara.visible {
  opacity: 1;
}


/* ────────────────────────────────────────
   7. #textbox（テキストボックス）
   画面下部に固定。クリックで次のセリフへ進む。
──────────────────────────────────────── */
#textbox {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38%;  /* 画面高さの 38% を占める。調整したい場合はここを変更 */
  background: var(--box-bg);
  border-top: 2px solid rgba(224, 94, 138, 0.25);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.4rem 1.2rem;
  gap: 0.5rem;
  backdrop-filter: blur(12px);  /* 背景のすりガラス効果 */
  cursor: pointer;
  user-select: none;
  box-shadow: 0 -4px 24px rgba(200, 100, 160, 0.1);
}

/* JS が .hidden を付与すると非表示になる（選択肢表示中など） */
#textbox.hidden {
  display: none;
}

/* 話者名（「彼氏」「私」など） */
#speaker {
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
  font-weight: 700;
  color: var(--rose);
  letter-spacing: 0.12em;
  min-height: 1.2em;  /* 話者名がないときもレイアウトが崩れないよう確保 */
}

@media (min-width: 540px) {
  #speaker { font-size: 0.95rem; }
}

/* セリフ・地の文 */
#text {
  font-size: clamp(0.9rem, 2.8vw, 1.05rem);
  line-height: 1.9;
  color: var(--text-dark);
  flex: 1;    /* 残りの高さを使い切る */
  overflow: hidden;
}

@media (min-width: 540px) {
  #text { font-size: 1.05rem; }
}

/* 次へアイコン（▼ が点滅）。タイピング完了後に JS が表示する */
#next-arrow {
  position: absolute;
  bottom: 0.8rem;
  right: 1.1rem;
  font-size: 0.75rem;
  color: var(--rose);
  opacity: 0.7;
  display: none;  /* JS が block に切り替えるまで非表示 */
  animation: blink 1.2s ease-in-out infinite;
}

/* 点滅アニメーション */
@keyframes blink {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 0.1; }
}


/* ────────────────────────────────────────
   8. #choices（選択肢ボタン）
   JS が動的にボタンを生成・削除します。
   ボタンの数やテキストはシナリオ JSON で管理します。
──────────────────────────────────────── */
#choices {
  position: absolute;
  bottom: 40%;  /* テキストボックスの上に重ならないよう調整 */
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 1.5rem;
  z-index: 20;
}

/* 各選択肢ボタン */
.choice-btn {
  background: rgba(255, 248, 252, 0.93);
  border: 1.5px solid rgba(224, 94, 138, 0.4);
  color: var(--text-dark);
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 2.8vw, 1rem);
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(200, 100, 150, 0.12);
}

.choice-btn:hover {
  background: linear-gradient(135deg, #fde8f0, #e8f0fd);
  border-color: var(--rose);
  transform: translateY(-2px);  /* 少し浮き上がる */
}

.choice-btn:active {
  transform: translateY(0);
}


/* ────────────────────────────────────────
   9. #line-cta（LINE 友だち追加 CTA）
   シナリオの name_input コマンドで表示されます。
   「〇〇ともっと仲良くなりたい」ボタンと
   「違うな…」（キャラ選択に戻る）ボタンで構成。
──────────────────────────────────────── */
#line-cta {
  position: absolute;
  bottom: 40%;
  left: 0;
  right: 0;
  z-index: 20;
  display: none;  /* JS が flex に切り替えるまで非表示 */
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.6rem 1.8rem 1.4rem;
  background: rgba(255, 248, 252, 0.94);
  border-top: 1.5px solid rgba(224, 94, 138, 0.25);
  border-bottom: 1.5px solid rgba(224, 94, 138, 0.25);
  backdrop-filter: blur(12px);
  box-shadow: 0 -2px 16px rgba(200, 100, 150, 0.1);
}

/* 「もっと仲良くなりたいと思ったら…」の文言 */
#line-cta-sub {
  font-size: clamp(0.78rem, 2.4vw, 0.88rem);
  color: var(--text-mid);
  letter-spacing: 0.1em;
  text-align: center;
}

/* LINE 友だち追加ボタン（グラデーション・丸角） */
.btn-line-cta {
  display: block;
  width: 100%;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, var(--coral), var(--rose), var(--lavender));
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 2.8vw, 1.05rem);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(240, 96, 122, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-line-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(240, 96, 122, 0.4);
}

/* 「違うな…」テキストリンク（キャラ選択に戻る） */
.btn-back-small {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: clamp(0.75rem, 2.2vw, 0.82rem);
  cursor: pointer;
  letter-spacing: 0.1em;
  padding: 0.2rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.btn-back-small:hover {
  color: var(--text-mid);
}


/* ────────────────────────────────────────
   10. #screen-select（キャラクター選択画面 S-03）
   共通シナリオが終わると表示されます。
   カード（.char-card）は JS が動的に生成します。
──────────────────────────────────────── */
#screen-select {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;  /* JS が flex に切り替えるまで非表示 */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(255, 182, 210, 0.3) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(173, 216, 255, 0.3) 0%, transparent 55%),
    linear-gradient(160deg, #fff4f8 0%, #fce8f3 50%, #edf4ff 100%);
  padding: 1.2rem;
}

/* 「気になる彼氏を選んでください」の文言 */
.select-title {
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
  letter-spacing: 0.35em;
  color: var(--text-mid);
  text-align: center;
}

/* カードを横並びにするコンテナ */
.cards {
  display: flex;
  gap: clamp(0.6rem, 2vw, 1.2rem);
  align-items: flex-end;
  width: 100%;
  justify-content: center;
}

/* 各キャラクターカード */
.char-card {
  position: relative;
  flex: 1;
  max-width: 200px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(180, 100, 150, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s cubic-bezier(.22, .68, 0, 1.2), box-shadow 0.3s ease;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
}

/* カードホバー：浮き上がって少し拡大 */
.char-card:hover {
  transform: translateY(-10px) scale(1.04);
  box-shadow:
    0 20px 48px rgba(180, 100, 150, 0.25),
    0 0 24px rgba(224, 94, 138, 0.18);
  border-color: rgba(224, 94, 138, 0.4);
}

.char-card:active {
  transform: translateY(-6px) scale(1.02);
}

/* 画像の表示エリア（通常画像とホバー画像を重ねる） */
.char-card .img-wrap {
  position: relative;
  height: clamp(200px, 45vh, 380px);
}

.char-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: opacity 0.3s ease;
}

/* ホバーで通常画像→笑顔画像に切り替え */
.char-card .img-hover         { opacity: 0; }
.char-card:hover .img-normal  { opacity: 0; }
.char-card:hover .img-hover   { opacity: 1; }

/* カード下部のグラデーションオーバーレイ（名前テキストの可読性確保） */
.char-card .card-grad {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(255, 240, 248, 0.96) 0%, transparent 100%);
}

/* キャラ名・タグのテキストエリア */
.char-card .card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: clamp(0.5rem, 1.5vw, 0.8rem) 0.6rem;
  text-align: center;
}

.char-card .card-name {
  font-size: clamp(0.72rem, 2.2vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.char-card .card-tag {
  font-size: clamp(0.55rem, 1.6vw, 0.7rem);
  color: var(--text-mid);
  letter-spacing: 0.05em;
}

/* 「タップして彼氏とのストーリーを始める」ヒントテキスト */
.select-hint {
  font-size: clamp(0.62rem, 1.8vw, 0.72rem);
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-align: center;
}


/* ────────────────────────────────────────
   11. #screen-ending（エンディング画面 S-05）
   各ルートのシナリオ終了後に表示されます。
   背景は立ち絵（夕焼け）が透けて見えるようにしています。
──────────────────────────────────────── */
#screen-ending {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;  /* JS が flex に切り替えるまで非表示 */
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;  /* コンテンツを画面下部に寄せる */
  padding-bottom: clamp(2rem, 6vh, 4rem);
  gap: 1.2rem;
  background: rgba(255, 248, 252, 0.5);  /* 半透明で背景が透けて見える */
  backdrop-filter: blur(2px);
}

/* 「〇〇と恋人になった。」メッセージ */
.ending-message {
  font-size: clamp(0.9rem, 2.8vw, 1.1rem);
  color: var(--text-dark);
  letter-spacing: 0.15em;
  text-align: center;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.8);
  margin-bottom: 0.4rem;
}

/* LINE ボタン（グラデーション・丸角） */
.btn-line {
  display: block;
  width: min(80%, 300px);
  padding: 1rem;
  background: linear-gradient(135deg, var(--coral), var(--rose), var(--lavender));
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(240, 96, 122, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-line:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(240, 96, 122, 0.4);
}

/* 「違うな…」ボタン（キャラ選択に戻る） */
.btn-back {
  background: transparent;
  border: 1.5px solid rgba(58, 32, 64, 0.25);
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  padding: 0.6rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: border-color 0.2s, color 0.2s;
}

.btn-back:hover {
  border-color: var(--text-mid);
  color: var(--text-mid);
}


/* ────────────────────────────────────────
   12. #game-view（ゲームビュー）
   背景・立ち絵・テキストボックスを内包する基本レイヤー。
──────────────────────────────────────── */
#game-view {
  position: absolute;
  inset: 0;
  z-index: 1;
}


/* ────────────────────────────────────────
   13. レスポンシブ対応（横向き端末）
   スマホを横向きにしたときのレイアウト調整。
──────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  /* 立ち絵を少し大きく */
  #chara {
    height: 90%;
  }

  /* テキストボックスを高くしてフォントを小さく */
  #textbox {
    height: 45%;
    padding: 0.6rem 1.2rem 0.8rem;
  }

  #text {
    font-size: 0.85rem;
    line-height: 1.6;
  }

  /* キャラ選択カードの高さを抑える */
  .char-card .img-wrap {
    height: clamp(120px, 35vh, 220px);
  }
}
