/* ============================================
   リセット & 基本設定
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', sans-serif;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  position: relative;
}


/* 背景レイヤー */
#bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
}

/* ============================================
   アバター表示エリア（全画面）
   ============================================ */
.avatar-main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#avatar-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   吹き出し（音声オフ時のみ表示）
   ============================================ */
.speech-bubble {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 500px;
  background: white;
  border-radius: 20px;
  padding: 24px 28px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
  animation: bubbleIn 0.3s ease;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -15px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 15px 15px 15px;
  border-color: transparent transparent white transparent;
}

.speech-bubble p {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: #1f2937;
}

.speech-bubble.hidden {
  display: none;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   チャット入力エリア（下部固定）
   ============================================ */
.chat-input-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

#userInput {
  flex: 1;
  border: 2px solid #e5e7eb;
  border-radius: 25px;
  padding: 12px 20px;
  font-size: 16px;
  outline: none;
  transition: all 0.2s;
  background: white;
}

#userInput:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mic-btn,
.send-btn {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mic-btn {
  background: white;
  color: #2563eb;
  border: 2px solid #2563eb;
  font-size: 20px;
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn:hover,
.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.mic-btn:active,
.send-btn:active {
  transform: translateY(0);
}

.mic-btn.listening {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.85;
  }
}

/* ============================================
   音声トグルボタン（右上固定）
   ============================================ */
.voice-toggle-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 200;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.voice-toggle-btn:active {
  transform: scale(0.95);
}

.voice-toggle-btn.voice-off {
  background: rgba(239, 68, 68, 0.95);
}

/* ============================================
   戻るリンク（左上固定）
   ============================================ */
.back-link-fixed {
  position: fixed;
  top: 20px;
  left: 20px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 25px;
  color: #1f2937;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 200;
  transition: all 0.2s;
}

.back-link-fixed:hover {
  background: white;
  transform: translateX(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* ============================================
   レスポンシブ（モバイル）
   ============================================ */
@media (max-width: 768px) {
  .speech-bubble {
    bottom: 90px;
    left: 5%;
    right: 5%;
    max-width: none;
    padding: 20px 24px;
    transform: none;
  }

  .speech-bubble p {
    font-size: 16px;
  }

  .chat-input-fixed {
    padding: 16px;
    gap: 10px;
  }

  #userInput {
    font-size: 16px;
    padding: 10px 16px;
  }

  .send-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .mic-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .voice-toggle-btn {
    width: 48px;
    height: 48px;
    font-size: 24px;
    top: 16px;
    right: 16px;
  }

  .back-link-fixed {
    top: 16px;
    left: 16px;
    padding: 10px 16px;
    font-size: 13px;
  }

  /* スマホではマイクボタンを非表示 */
  .mic-btn {
    display: none;
  }
}
