/* ======================================
   AngeLiar - Chloe チャット画面スタイル
   ====================================== */
@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@300;400;500&display=swap');

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

/* --- ベース --- */
body {
  background: #000;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- PC背景ぼかし（9:16より横長の画面で表示） --- */
#bg-blur {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.35);
  transform: scale(1.12);
  z-index: 0;
  pointer-events: none;
}

/* モバイル（縦長：9:16より縦長）は不要 */
@media (max-aspect-ratio: 9/16) {
  #bg-blur { display: none; }
}

/* --- 入店オーバーレイ --- */
#enter-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  cursor: pointer;
}

#enter-age {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic Pro', sans-serif;
  font-size: 11px;
  color: rgba(255, 200, 220, 0.55);
  letter-spacing: 0.15em;
}

#enter-overlay.hidden {
  display: none;
}

#enter-btn {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic Pro', sans-serif;
  font-weight: 400;
  color: #7a1040;
  font-size: 15px;
  letter-spacing: 0.22em;
  border: 1px solid rgba(200, 100, 150, 0.4);
  padding: 16px 44px;
  border-radius: 32px;
  backdrop-filter: blur(12px);
  background: #ffd6ec;
  box-shadow: 0 0 24px rgba(240,160,200,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}

/* --- ステージ（9:16固定） --- */
#stage {
  position: relative;
  width: min(100dvw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100dvw * 16 / 9));
  overflow: hidden;
  z-index: 1;
}

/* モバイルは全画面表示（黒帯なし） */
@media (max-aspect-ratio: 9/16) {
  #stage {
    width: 100dvw;
    height: 100dvh;
  }
}

/* --- アバター共通 --- */
#avatar-idle, #avatar-idle-video, #avatar-thinking, #avatar-talking {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
}

/* --- 静止画は最下層（フォールバック） --- */
#avatar-idle {
  z-index: 1;
}

/* --- idle動画 --- */
#avatar-idle-video {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#avatar-idle-video.active {
  opacity: 1;
}

/* --- thinking動画 --- */
#avatar-thinking {
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#avatar-thinking.active {
  opacity: 1;
}

/* --- talking動画は最上層 --- */
#avatar-talking {
  z-index: 4;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#avatar-talking.active {
  opacity: 1;
}

/* --- テロップ（SHOW_SUBTITLE=true のとき表示） --- */
#reply-bubble {
  position: absolute;
  z-index: 5;
  top: max(24px, env(safe-area-inset-top));
  left: 24px;
  right: 24px;
  background: rgba(0, 0, 0, 0.6);
  color: #f0c0d8;
  font-family: 'Hiragino Kaku Gothic Pro', 'Noto Sans JP', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 16px;
  backdrop-filter: blur(8px);
  display: none;
}

#reply-bubble.visible {
  display: block;
}

/* --- メニュートリガー --- */
@keyframes angel-glow {
  0%, 100% {
    box-shadow:
      0 0 10px rgba(240,160,200,0.4),
      0 0 24px rgba(240,160,200,0.15),
      0 4px 16px rgba(0,0,0,0.25);
  }
  50% {
    box-shadow:
      0 0 18px rgba(240,160,200,0.65),
      0 0 36px rgba(240,160,200,0.25),
      0 4px 16px rgba(0,0,0,0.25);
  }
}

#menu-trigger {
  position: absolute;
  z-index: 5;
  right: 20px;
  bottom: 248px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(240, 192, 216, 0.55);
  background: rgba(255, 214, 236, 0.65);
  color: #7a1040;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, border-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: angel-glow 3s ease-in-out infinite;
}

#menu-trigger.open {
  transform: rotate(45deg) scale(1.05);
  background: rgba(200, 40, 90, 0.7);
  border-color: rgba(240, 80, 140, 0.7);
  animation: none;
  box-shadow: 0 0 18px rgba(240,80,140,0.5), 0 4px 16px rgba(0,0,0,0.3);
}

/* --- チャット上部横並びメニューバー --- */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

#menu-bar {
  position: absolute;
  z-index: 5;
  bottom: 82px;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 4px 20px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 20px, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 20px, black calc(100% - 40px), transparent 100%);
}

#menu-bar::-webkit-scrollbar { display: none; }

#menu-bar.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.bar-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(255, 230, 242, 0.1);
  border: 1px solid rgba(240, 192, 216, 0.3);
  border-radius: 18px;
  padding: 12px 16px;
  cursor: pointer;
  min-width: 96px;
  backdrop-filter: blur(20px);
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, background 0.2s ease;
}

/* キャスドリカードのシマーボーダー（ピンク×ローズ） */
.bar-item[data-action="castdori"] {
  background: rgba(255, 220, 238, 0.13);
  border-color: transparent;
}

.bar-item[data-action="castdori"]::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 18px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,180,220,0.7) 25%,
    rgba(232,56,109,0.9) 50%,
    rgba(255,180,220,0.7) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2.5s linear infinite;
  z-index: -1;
}

.bar-item[data-action="castdori"]::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 17px;
  background: url('/images/chloe/card_test/card_B_banner.png') center / cover no-repeat;
  z-index: -1;
}

.bar-item[data-action="castdori"] .bar-name {
  color: #ffcce8;
}

.bar-item[data-action="castdori"] .bar-desc {
  color: rgba(255, 180, 220, 0.8);
}

.bar-item[data-action="castdori"] .bar-icon {
  filter: drop-shadow(0 0 4px rgba(200, 60, 120, 0.5));
}

.bar-item:active:not(:disabled) { transform: scale(0.95); }

.bar-item.bar-locked {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255,255,255,0.08);
}

.bar-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 5px rgba(255,160,210,0.6));
}

.bar-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  overflow: visible;
}


.bar-thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  border: 2px solid rgba(255, 180, 220, 0.6);
  box-shadow: 0 0 8px rgba(200, 40, 90, 0.3);
}

.bar-item.bar-locked .bar-icon {
  filter: none;
  opacity: 0.5;
}

.bar-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.95);
}

.bar-desc {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic Pro', sans-serif;
  font-weight: 300;
  font-size: 9px;
  color: rgba(255, 192, 220, 0.85);
  text-align: center;
  line-height: 1.4;
  max-width: 88px;
}

.bar-item.bar-locked .bar-desc {
  font-family: 'Hiragino Kaku Gothic Pro', 'Noto Sans JP', sans-serif;
  font-style: normal;
  color: rgba(255,255,255,0.3);
}

/* --- 無料時間カウントダウン --- */
#free-timer {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}
#free-timer.billing {
  color: #ff7eb3;
}

/* --- 入力エリア --- */
#input-area {
  position: absolute;
  z-index: 5;
  bottom: max(32px, calc(env(safe-area-inset-bottom) + 16px));
  left: 24px;
  right: 24px;
  display: flex;
  gap: 8px;
}

#user-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  padding: 12px 18px;
  color: #fff;
  font-size: 14px;
  font-family: 'Hiragino Kaku Gothic Pro', 'Noto Sans JP', sans-serif;
  outline: none;
  backdrop-filter: blur(8px);
}

#user-input::placeholder { color: rgba(255, 255, 255, 0.5); }

#send-btn {
  background: #c8285a;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#send-btn:disabled {
  background: #444;
  cursor: not-allowed;
}

/* --- キーボード表示中: メニュー非表示 --- */
#stage.kb-open #menu-trigger,
#stage.kb-open #menu-bar,
#stage.kb-open #free-timer {
  display: none;
}

/* --- キャスドリ動画 --- */
@keyframes castdori-zoom {
  from { transform: scale(1);    }
  to   { transform: scale(1.14); }
}

#avatar-castdori {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transform-origin: center top;
  transition: opacity 0.3s ease;
}

#avatar-castdori.active {
  opacity: 1;
}

#avatar-castdori.zoom {
  animation: castdori-zoom 0.35s cubic-bezier(0.25, 0, 0.5, 1) forwards;
}

/* --- キャスドリ幕 --- */
#castdori-curtain {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #0d0008;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#castdori-curtain.active {
  opacity: 1;
  pointer-events: auto;
}

/* --- キャスドリ確認モーダル --- */
#castdori-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#castdori-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

#castdori-modal-inner {
  background: url('/images/chloe/card_test/card_C_gacha.png') center / cover no-repeat;
  border-radius: 16px;
  padding: 36px 28px 24px;
  width: min(260px, 78vw);
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.castdori-modal-grade {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 13px;
  color: rgba(255, 200, 230, 0.9);
  letter-spacing: 0.1em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.castdori-modal-copy {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.05em;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.castdori-modal-pt {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 22px;
  font-weight: 500;
  color: #ffb0d0;
  margin: 4px 0 12px;
  text-shadow: 0 0 12px rgba(255, 100, 160, 0.6);
}

#castdori-confirm-btn {
  width: 100%;
  background: #c8285a;
  border: none;
  border-radius: 24px;
  padding: 14px;
  color: #fff;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

#castdori-cancel-btn {
  background: none;
  border: none;
  color: #a0245a;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.7;
}

/* 名前設定モーダル */
#name-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#name-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

#name-modal-inner {
  background: #ffd6ec;
  border-radius: 24px 24px 16px 16px;
  padding: 28px 32px 24px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#name-modal-title {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: #7a1040;
  letter-spacing: 0.05em;
}

#name-modal-sub {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 12px;
  color: #a0245a;
  opacity: 0.8;
  text-align: center;
}

#name-input-wrap {
  width: 100%;
  position: relative;
}

#name-input {
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 2px solid #e8a0c0;
  border-radius: 12px;
  padding: 12px 40px 12px 16px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 16px;
  color: #7a1040;
  outline: none;
}

#name-input:focus {
  border-color: #c8285a;
}

#name-char-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #a0245a;
  opacity: 0.6;
}

#name-truncate-notice {
  width: 100%;
  background: rgba(200, 40, 90, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  box-sizing: border-box;
}

#name-truncate-text {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 12px;
  color: #7a1040;
  text-align: center;
  line-height: 1.6;
}

#name-confirm-btn {
  width: 100%;
  background: #c8285a;
  border: none;
  border-radius: 24px;
  padding: 14px;
  color: #fff;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
  margin-top: 4px;
}

#name-skip-btn {
  background: none;
  border: none;
  color: #a0245a;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.7;
}
