/* One-image, lightweight Face AI dock that keeps the world visible. */
.world-intro {
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.world-intro-copy {
  width: min(430px, 100%);
  max-height: 100%;
  justify-content: center;
}

.intro-ai-portrait {
  width: clamp(180px, 28vw, 260px);
  height: clamp(180px, 28vw, 260px);
  flex: 0 1 auto;
  overflow: hidden;
  border: 1px solid rgba(143, 211, 255, .62);
  border-radius: 32px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .58), 0 0 42px rgba(61, 177, 239, .3);
}

.intro-ai-portrait .intro-ai-avatar {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: inherit;
  box-shadow: none;
  object-position: center;
}

.face-ai-portrait { position: relative; }
.face-ai-portrait img { display: block; }
.face-ai-eye,
.face-ai-mouth {
  position: absolute;
  z-index: 2;
  display: block;
  pointer-events: none;
}
.face-ai-eye {
  top: 40.2%;
  width: 7.2%;
  height: 2.4%;
  border-radius: 55% 55% 45% 45%;
  background: linear-gradient(180deg, rgba(32, 20, 18, .92), rgba(121, 76, 60, .72));
  box-shadow: 0 1px 1px rgba(0, 0, 0, .55);
  opacity: 0;
  transform: scaleY(.08);
  transform-origin: center;
  animation: faceAiBlink 6.4s ease-in-out infinite;
}
.face-ai-eye-left { left: 40.4%; }
.face-ai-eye-right { right: 40.2%; animation-delay: .025s; }
.face-ai-mouth {
  left: 46.1%;
  top: 51.8%;
  width: 8%;
  height: 1.45%;
  border-radius: 50%;
  background: rgba(72, 24, 28, .7);
  box-shadow: inset 0 1px rgba(248, 174, 164, .24), 0 1px rgba(0, 0, 0, .28);
  opacity: 0;
  transform: scale(.86, .35);
}
.face-ai-speaking .face-ai-mouth {
  opacity: .5;
  animation: faceAiQuietSpeech .42s ease-in-out infinite alternate;
}
.world-intro.navigator-speaking .intro-language,
.world-intro.navigator-speaking #enterWorldWithSound,
.world-intro.navigator-speaking #enterWorldSilent { display: none; }
.world-intro.playing .intro-ai-portrait { display: none; }

@keyframes faceAiBlink {
  0%, 91%, 95%, 100% { opacity: 0; transform: scaleY(.08); }
  93% { opacity: .9; transform: scaleY(1); }
}
@keyframes faceAiQuietSpeech {
  from { transform: scale(.88, .32); }
  to { transform: scale(1, .72); }
}
@media (prefers-reduced-motion: reduce) {
  .face-ai-eye,
  .face-ai-speaking .face-ai-mouth { animation: none; }
}

@media (max-width: 700px) {
  .world-intro-copy {
    height: 100%;
    gap: clamp(8px, 1.8vh, 14px);
  }

  .world-intro-copy > span {
    font-size: 9px;
    letter-spacing: .34em;
  }

  .intro-ai-portrait {
    width: min(76vw, 35dvh, 310px);
    height: min(76vw, 35dvh, 310px);
    margin: 0;
    border-radius: 28px;
  }

  .intro-ai-title b { font-size: 21px; }
  .intro-language { gap: 5px; }
  .intro-language select {
    width: min(300px, 84vw);
    min-width: 0;
    height: 42px;
  }
  .world-intro #enterWorldWithSound {
    width: min(330px, 88vw);
    min-width: 0;
    padding: 14px 18px 12px;
  }
}

@media (max-width: 380px), (max-height: 660px) {
  .intro-ai-portrait {
    width: min(64vw, 28dvh, 220px);
    height: min(64vw, 28dvh, 220px);
  }
  .intro-ai-title b { font-size: 18px; }
  .intro-ai-title small { margin-top: 3px; }
  .intro-language select { height: 38px; }
  .world-intro #enterWorldWithSound { padding: 11px 15px 10px; }
}

.face-ai-companion {
  left: 12px;
  top: auto;
  bottom: 14px;
  width: 62px;
  padding: 4px;
  border-radius: 16px;
  transform: none;
}

.face-ai-companion img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}
.face-ai-portrait-small { width: 52px; height: 52px; overflow: hidden; border-radius: 12px; }
.face-ai-portrait-small img { width: 100%; height: 100%; object-fit: cover; }

.face-ai-companion span { padding: 5px 1px 2px; }
.face-ai-companion small { display: none; }

.face-ai-panel {
  left: 50%;
  right: auto;
  top: auto;
  bottom: 14px;
  width: min(560px, calc(100vw - 170px));
  max-height: none;
  padding: 11px 12px;
  border-radius: 15px;
  background: rgba(3, 14, 25, .96);
  backdrop-filter: blur(16px);
  transform: translate(-50%, 10px);
}

.face-ai-panel.open { transform: translate(-50%, 0); }
.face-ai-panel header { padding-bottom: 7px; }
.face-ai-panel header small { display: none; }
.face-ai-panel header button { width: 28px; height: 28px; font-size: 18px; }
.face-ai-message {
  min-height: 0;
  max-height: 58px;
  overflow: auto;
  margin: 8px 0;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
}

.face-ai-panel input { height: 40px; }
.face-ai-panel form button { padding: 0 11px; }
.face-ai-voice { height: 42px; margin-top: 6px; font-size: 12px; letter-spacing: .06em; }
.face-ai-voice.preparing {
  border-color: #e8c77d;
  background: linear-gradient(135deg, #806024, #c59a48);
}

@media (max-width: 700px) {
  .face-ai-companion { left: 8px; bottom: 8px; width: 54px; }
  .face-ai-companion img { width: 44px; height: 44px; }
  .face-ai-portrait-small { width: 44px; height: 44px; }
  .face-ai-panel {
    left: 68px;
    right: 8px;
    bottom: 8px;
    width: auto;
    padding: 9px;
    transform: translateY(8px);
  }
  .face-ai-panel.open { transform: none; }
  .face-ai-panel header { padding-bottom: 5px; }
  .face-ai-message {
    min-height: 0;
    max-height: 54px;
    margin: 6px 0;
    font-size: 12px;
  }
  .face-ai-panel input { height: 38px; }
  .face-ai-voice { height: 40px; font-size: 12px; }
}
