html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
}

#hud {
  position: fixed;
  top: env(safe-area-inset-top, 12px);
  left: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#hud-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#hud-hint {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.4;
}

#hud-meta {
  margin-top: 4px;
  display: flex;
  gap: 12px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

#hud-meta #self-label {
  font-weight: 600;
}

#hud a {
  color: #4cc3d9;
  pointer-events: auto;
}

#pose-debug {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  color: #dfe;
  max-width: fit-content;
}

#startpanel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  padding: 16px;
  pointer-events: none;
}

#start-btn {
  pointer-events: auto;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  background: #4cc3d9;
  color: #001a20;
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#start-btn:disabled {
  opacity: 0.4;
}

#status {
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  text-align: center;
  max-width: 90%;
}

#ua {
  font: 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(255, 255, 255, 0.5);
  max-width: 90%;
  text-align: center;
  overflow-wrap: anywhere;
}

/* フォールバック時のカメラ映像背景 */
#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 0;
  background: #000;
  display: none;
}

/* a-scene の canvas は透過して映像を透かす。z-index で video より前 */
.a-canvas {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 1 !important;
}

/* 仮想スティック */
#joystick {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom, 20px), 20px);
  right: 20px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  z-index: 30;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: none;
  pointer-events: auto;
}

.joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  margin-left: -23px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  pointer-events: none;
  transition: transform 0.05s linear;
}

/* コンパニオン (ロボット) の会話バブル */
#companion-dialogue {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom, 32px), 32px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(500px, 88vw);
  padding: 12px 44px 12px 20px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  z-index: 25;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  display: none;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.08s ease-out;
}

#companion-dialogue:active {
  transform: translateX(-50%) scale(0.97);
}

#companion-dialogue::after {
  content: "›";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: 0.55;
}

#companion-dialogue::before {
  content: "";
  margin-right: 0;
}
#companion-dialogue.kind-robot::before {
  content: "🤖";
  margin-right: 6px;
}
#companion-dialogue.kind-person::before {
  content: "👤";
  margin-right: 6px;
}
